javascript - AngularJS not displaying JSON response in view -
updated requested more info:
i have controller calls web method , want returned json binded variable in controller called applications. alert displays json correctly see nothing in view.
note have tried $scope , 'this' in controller manual data , 'this' worked why have use instead of $scope below.
app.controller('appscontroller', function ($http, $scope) { $http.post('/webmethod/dostuff', {}). success(function (data, status, headers, config) { alert(data); this.applications = data; }) }
my view this
<div class="container" ng-controller="appscontroller appctrl"> <div class="row" ng-repeat="application in appctrl.applications"> <div class="col-xs-6 applicationname" ng-click="appctrl.expand($index)">{{application.name}}</div> </div></div>
json like
[ { name: "application 1", alerts: "2", status: "red", notifications: [ { header: "notification header 1", updatetype: "new", message: "hello world", starttime: "11:00", endtime: "12:00" } ], expanded: false }]
this
not expect be. try this:
app.controller('appscontroller', function ($http, $scope) { var self = this; $http.post('/webmethod/dostuff', {}). success(function (data, status, headers, config) { alert(data); //or can use $scope.applications = data; instead self.applications = data; }) }
see how "this" keyword work? explanation of this
in javascript.
Comments
Post a Comment