Your "JSON file" is not a valid JSON at all - you need to quote keys for a given JSON to be valid. JSON != JS object.
Cheers, Pawel On Tue, Jan 20, 2015 at 11:09 AM, Suk Khoi <[email protected]> wrote: > i am learning angular following angular 50 examples but got stuck, iam > typing the same thing, but its not working > iam following this tutorial > > https://www.youtube.com/watch?v=TRrL5j3MIvo > > trying to read countries from json > json file is > == > > [ > {name: 'Afghanistan', code: 'AF'}, > {name: 'Ă…land Islands', code: 'AX'}, > {name: 'Albania', code: 'AL'}, > {name: 'Algeria', code: 'DZ'}, > {name: 'American Samoa', code: 'AS'}, > {name: 'AndorrA', code: 'AD'}, > {name: 'Angola', code: 'AO'}, > {name: 'Anguilla', code: 'AI'}, > {name: 'Antarctica', code: 'AQ'}, > {name: 'Antigua and Barbuda', code: 'AG'}, > {name: 'Argentina', code: 'AR'}, > {name: 'Armenia', code: 'AM'}, > {name: 'Aruba', code: 'AW'}, > {name: 'Australia', code: 'AU'}, > {name: 'Austria', code: 'AT'}, > ] > > ==== > and the code is > <html ng-app="countryApp"> > <head> > <meta charset="utf-8"> > <title>angular country expa</title> > <script src="angular.js"></script> > <script> > var counryApp=angular.module('countryApp',[]); > counryApp.controller('countryCtrl',function($scope,$http) > { > > $http.get('countries.json').success(function(data) > > { > > $scope.countries=data; > }); > }); > </script> > > </head> > <body ng-controller="countryCtrl"> > <table> > <tr ng-repeat="country in countries"> > <td> > {{country.name}} > </td> > </tr> > </table> > </body> > </html> > > iam using brackets > > and the error is > > at Object.parse (native) > at fromJson (http://127.0.0.1:1349/angular.js:1139:14) > at defaults.defaults.transformResponse > (http://127.0.0.1:1349/angular.js:7522:18) > at http://127.0.0.1:1349/angular.js:7470:12 > at forEach (http://127.0.0.1:1349/angular.js:325:18) > at transformData (http://127.0.0.1:1349/angular.js:7469:3) > at transformResponse (http://127.0.0.1:1349/angular.js:8188:17) > at wrappedCallback (http://127.0.0.1:1349/angular.js:11682:81) > at http://127.0.0.1:1349/angular.js:11768:26 > at Scope.$eval (http://127.0.0.1:1349/angular.js:12811:28) > http://127.0.0.1:1349/index.html Failed to load resource: > net::ERR_CACHE_MISS > > -- > You received this message because you are subscribed to the Google Groups > "AngularJS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. -- AngularJS book: http://www.packtpub.com/angularjs-web-application-development/book Looking for bootstrap-based widget library for AngularJS? http://angular-ui.github.com/bootstrap/ -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
