angularjs - $resouce response data is not updated on html -


i not amount updated on ui, when network, able see response value. there wrong code, not familiar $resource , new angularjs.

 <ion-view title="hsf" id="page4">         <ion-content overflow-scroll="true" padding="true" class="has-header">             <h3 id="hsf-heading5" style="color:#000000;text-align:center;">summary</h3>              <ion-scroll>                 <ul class="list" data-ng-repeat="mth in monthlist()">                     <li class="item item-positive" ng-click="">                         {{mth.label}}                         <span style="float: right;">total: ${{mth.amount}}</span>                     </li>                 </ul>             </ion-scroll>         </ion-content>     </ion-view>       .factory('restservice',['$resource', function($resource){             return $resource('http://xxx/' + 'transaction', {id: '@id'},{                 readsales: {                     method: 'post',                     isarray: false                 }             });         }])          .controller('hsfctrl', function($scope, $http, $state, restservice) {          //region yearlysales         var list = [];         var today = new date();         var yearindex = today.getfullyear();         var yearobj = {             label: "",             amount:0         };         yearobj.label = yearindex;         $http({             url: 'http://xxx/' + 'transaction',             data: {"type": 3, "datetime": yearobj.label},             method: 'post'         }).success(function (response) {             yearobj.amount = response;         });         list.push(yearobj);         $scope.yearlist = list;     //endregion           //region monthlysales         $scope.monthlist = [];         var months = [1,2,3,4,5,6,7,8,9,10,11,12,13];         var monthnames = [ 'january', 'february', 'march', 'april', 'may', 'june',             'july', 'august', 'september', 'october', 'november', 'december' ];         for(var mth in months){             $scope.amount = {};             var monthobj = {                 label: "",                 amount: 0             };             var objtosend = {                 type: 2,                 datetime: '2016' + '-' + mth             };             //console.log(mth);             var read = restservice.readsales(objtosend);             read.$promise.then(function(result){                 monthobj.amount = number(result);             });               monthobj.label = monthnames[mth];             $scope.monthlist.push(monthobj);         }         //console.log($scope.monthlist);         //endregion           $scope.gotomsp = function(){             $state.go('tabscontroller.msp');         }      }); 

the response object has property:

data – {string|object} – response body transformed transform functions.

so have pass response in variable this:

yearobj.amount = response.data; 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -