Script.js
var app=angular.module("myapp",["panelModule"]);
var store=this;
store.products=[];
//following code yield proper output
// app.controller("StoreController",function () {
// this.products=data; //data is a array of object defined in same file
// });
app.controller("StoreController",['$http',function($http){
return $http.get('js/data.json').then(onDataReceive);
}]);
var onDataReceive=function(response) {
store.products.push(...response.data);
console.log(store.products); //this shows [object, object] in browser console
};
I m basically iterating over the array of object with ng-repeat in my view( index.html) But it is not getting update when i used $http service.However static data is getting displayed properly. I m going thru some online AngularJs tutorial. I m new to AngularJs. Please point me out what i m doing wrong here? Thanks
storeproperty andonDataReceivefunction outside of the controllers?storeoutside Angular? I really suggest you going through the Angular tutorial so that you acquire the basics.