Get Ajax data into Angular grid

Using Angular Grid, I get the ajax get data in console.log. But an empty grid. The console log reads: [13:56:11.411] now!! [13:56:11.412] [] [13:56:11.412] now!! [13:56:11.556] This is the js file. // main.js var app = angular.module('myApp', ['ngGrid']); var getData = []; function fetchData() { var mydata = []; $.ajax({ url:'/url/to/hell', type:'GET', success: function(data) { for(i = 0, j = data.length; i < j; i++) { mydata[i] = data[i]; } getData = mydata; console.log(getData); } }); } fetchData(); app.controller('MyCtrl', function($scope) { console.log('now!!') console.log(getData) console.log('now!!') $scope.myData = getData $scope.gridOptions = { data: 'myData', showGroupPanel: true }; }); New Js file: // main.js var app = angular.module('myApp', ['ngGrid']); app.controller('MyCtrl', function($scope, $http) { function fetchData() { $http({ url:'/url/to/hell', type:'GET'}) .success(function(data) { $scope.myData = data; $scope.gridOptions = { data: 'myData', showGroupPanel: true }; }); } fetchData(); }); HTML file. Blank Title 3

以上就是Get Ajax data into Angular grid的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏