-1

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

                });
    }
user8427641
  • 127
  • 10
  • Did you initialize this object globally `$scope.savedSearchList =[ ]`? – Ramesh Rajendran Aug 24 '17 at 11:59
  • I tried that but still no difference. – user8427641 Aug 24 '17 at 12:01
  • Can you show me the console result of $scope.savedSearchList ?\ – Ramesh Rajendran Aug 24 '17 at 12:04
  • data : Array(4) 0 : {id: 135, title: "ssss", employerId: 0, ownerId: 39424, createdBy: 0, …} 1 : {id: 136, title: "ssssu", employerId: 0, ownerId: 39424, createdBy: 0, …} 2 : {id: 137, title: "yy", employerId: 0, ownerId: 39424, createdBy: 0, …} 3 : {id: 138, title: "ssfsdf", employerId: 0, ownerId: 39424, createdBy: 0, …} – user8427641 Aug 24 '17 at 12:06
  • How about using a model like `$scope.search = { savedSearchList: [] }`. I wonder if you are getting scoping issues. Then `ng-repeat="s in search.savedSearchList"` – Brian Aug 24 '17 at 12:31
  • Not sure how to use this as for me its getting filled by a service – user8427641 Aug 24 '17 at 13:50

1 Answers1

0

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

rrd
  • 5,789
  • 3
  • 28
  • 36
  • I have just followed your suggestion but scope changes are still not reflecting in my view. Yes i do have method names sucessNotify. Have updated the above code accordingly. – user8427641 Aug 24 '17 at 11:59