simple error, whats wrong

38 views
Skip to first unread message

Suk Khoi

unread,
Jan 20, 2015, 5:09:45 AM1/20/15
to ang...@googlegroups.com
i am learning angular following angular 50 examples but got stuck, iam typing the same thing, but its not working
iam following this tutorial


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 defaults.defaults.transformResponse (http://127.0.0.1:1349/angular.js:7522:18)
    at transformResponse (http://127.0.0.1:1349/angular.js:8188:17)
http://127.0.0.1:1349/index.html Failed to load resource: net::ERR_CACHE_MISS

Pawel Kozlowski

unread,
Jan 20, 2015, 5:21:16 AM1/20/15
to ang...@googlegroups.com
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
> --
> 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 angular+u...@googlegroups.com.
> To post to this group, send email to ang...@googlegroups.com.
> 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/

Sukhoi

unread,
Jan 20, 2015, 6:13:15 AM1/20/15
to ang...@googlegroups.com
thanks it worked
> You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/39fGy_-YiSE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
> To post to this group, send email to ang...@googlegroups.com.
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.



--

Man Behind A Firewall
Reply all
Reply to author
Forward
0 new messages