angularjs - Can't get $http.get to work in Ionic app -


i'm trying build first ionic app , use simple list population using $http.get , json. have this:

.controller('reporttabctrl', function($scope) {  $scope.items = [ { id: 0 }, { id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }, { id: 6 }, { id: 7 }, { id: 8 }, { id: 9 }, { id: 10 }, { id: 11 }, { id: 12 }, { id: 13 }, { id: 14 }, { id: 15 }, { id: 16 }, { id: 17 }, { id: 18 }, { id: 19 }, { id: 20 }, { id: 21 }, { id: 22 }, { id: 23 }, { id: 24 }, { id: 25 }, { id: 26 }, { id: 27 }, { id: 28 }, { id: 29 }, { id: 30 }, { id: 31 }, { id: 32 }, { id: 33 }, { id: 34 }, { id: 35 }, { id: 36 }, { id: 37 }, { id: 38 }, { id: 39 }, { id: 40 }, { id: 41 }, { id: 42 }, { id: 43 }, { id: 44 }, { id: 45 }, { id: 46 }, { id: 47 }, { id: 48 }, { id: 49 }, { id: 50 } ]; }); 

and works great. list populated should. want move contents of $scope.items external file (to able generate dynamically) , call using $http.get.

i've tried without success:

.controller('reporttabctrl', function($scope, $http) { $http.get('items.json')     .success(function(data) {         $scope.items = data;     }) }); 

the content of items.json file same $scope.items variable.

what doing wrong?

/carl

you need put " double qoutes aside id property in each element of items.json make valid json

items.json

[   { "id": 0 },   { "id": 1 },   { "id": 2 }   // , on   //.   //. ] 

demo plunkr


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -