即使在使用 $apply 之后 $scope 也没有更新

$scope not updating even after using $apply

我正在从 $scope.saveSearchList 重新排序下拉列表,在我看来如下:

<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) {

                });
    }

我建议将您的第二个回调 'response' 重命名为其他名称。

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' 的方法。