即使使用$apply,$scope也不会更新



我在下面的视图中从$scope.saveSearchList中重新生成一个dropdoun列表:

<div class="form-group" ng-controller="TalentPoolController">
<md-input-container ng-init="SchoolSavedSearches(39424,2,true)"
class="md-block" style="margin:0 !important;">
<md-select ng-model="selectedSavedsearch"
placeholder="Select a Saved Search" id="Md-select2">
<md-option ng-value="s" ng-repeat="s in savedSearchList">{{s.title}}</md-option>
</md-select>                                          
</md-input-container>
</div>

在我的控制器中,我正在更新$scope.saveSearchList,但它似乎没有反映我的观点。请问我该如何解决这个问题?

TalentPoolService.insertSaveSearch(pvarrData)
.then(function successCallback(response) {
if (response.data.status == true) {
TalentPoolService.sucessNotify("Saved Search have been created successfully.", 5000, 640);
TalentPoolService.GetSchoolSavedSearches(39424, 2, true)
.then(function successCallback(schoolResponse) {
$scope.savedSearchList = schoolResponse.data;
$scope.$apply();
}, function errorCallback(schoolResponse) {
});
}

我建议将第二个回调的"响应"重命名为其他内容。

TalentPoolService.insertSaveSearch(pvarrData)
.then(function successCallback(response) {
if (response.data.status == true) {
TalentPoolService.sucessNotify("Saved Search have been created successfully.", 5000, 640);
TalentPoolService.GetSchoolSavedSearches(39424, 2, true)
.then(function successCallback(schoolResponse) {
$scope.savedSearchList = schoolResponse.data;
$scope.$apply();
}, function errorCallback(response) {
});
}

此外,您的TalenPoolService.sucessNotify <拼写错误,除非您有一个名为"sucessNotify"的方法。>

最新更新