user8427641
user8427641

Reputation: 127

$scope not updating even after using $apply

I am redering a dropdoun list from $scope.saveSearchList in my view below:

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

In my controller I am updating the $scope.saveSearchList but it doesn't seems to be reflecting my view. How do i resolve this please?

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

                });
    }

Upvotes: -1

Views: 43

Answers (1)

rrd
rrd

Reputation: 5957

I would suggest renaming your second callback's 'response' to something else.

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

      });
    }

Also, you have TalenPoolService.sucessNotify <- spelled wrong, unless you have a method called 'sucessNotify'.

Upvotes: 0

Related Questions