rest - Getting response but view is not updating - AngularJS -


i trying response url , populate in view, not see view getting updated. me resolve issue. thanks

source

<!doctype html> <html ng-app="mymodule"> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script> </head> <body ng-init="pricelist='promo03'"> <div ng-controller="pricingcontroller" >     <div ng-repeat="item in finallist track $index">     <ul>         <li>actual price: {{item.actualprice}}</li>         <li>button: {{item.button}}</li>         <li>content: {{item.content}}</li>         <li>description: {{item.description}}</li>         <li>discounted price: {{item.discountedprice}}</li>     </ul>     </div> </div> <script> var mymodule = angular.module('mymodule',[]); mymodule.service('bannerservice', ['$http', function ($http) {     this.getbannerlist = function (id, success) {         invokehttp('https://poctest1.firebaseio.com/pricing/' + id + '.json', success);     }     var invokehttp = function (url, callback) {         var value = $http({ method: 'get', url: url }).             success(function (data) {                 callback(data);             }).error(function () {                 callback(null);             });             return value;     }; }]);  mymodule.controller('pricingcontroller',['$scope','bannerservice', function($scope, bannerservice){     $scope.finallist = [];     var finalarray = [];     $scope.splitarray= function(){         $scope.array = $scope.pricelist.split(",");     };     $scope.callservice = function(){         for(i = 0; < $scope.array.length; i++){             //console.log(bannersupportservice.fetch($scope.array[i]));              bannerservice.getbannerlist($scope.array[i], function(banner){             if(banner != null){                 finalarray.push(angular.tojson(banner));             }                if(i == $scope.array.length){                 $scope.finallist = finalarray;                 console.log('final'+$scope.finallist);             }         });         }     };      $scope.splitarray();     $scope.callservice();  }]); </script> </body> </html> 

console output

final{"actualprice":10,"button":"check availability","content":"£5 6 months, £10 month further 6","description":"fiber broadband","discountedprice":5} 

html actual output

actual price: button: content: description: discounted price: 

html expected output

actual price: 10 button: check availability content: £5 6 months, £10 month further 6 description: fiber broadband discounted price: 5 

final{"actualprice":10,"button":"check availability","content":"£5 6 months, £10 month further 6","description":"fiber broadband","discountedprice":5}

this output represents object not array, suppose wait array. therefore ng-repeat prints nothing. should like:

[   {     "actualprice": 10,     "button": "check availability",     "content": "£5 6 months, £10 month further 6",     "description": "fiber broadband",     "discountedprice": 5   } ] 

your service works fix controller part


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -