Solved

Help with AngularJS - reading JSON file

Posted on 2015-01-12
2
139 Views
Last Modified: 2015-01-14
Hi..
Can you please tell me why this simple sample does not run.
Uncaught Error: [$injector:modulerr] Failed to instantiate


<div ng-app="app" ng-controller="ctrl">
  {{catalog}}
</div>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js"></script>



var app = angular.module('app', ['jsonService']);

angular.module('jsonService', ['ngResource'])
.factory('JsonService', function($resource) {
  return $resource('https://s3-us-west-2.amazonaws.com/s.cdpn.io/93930/catalog.json');
});

app.controller('ctrl', function($scope, JsonService){
  JsonService.get(function(data){
    $scope.catalog = data;
  });
});
0
Comment
Question by:JElster
2 Comments
 
LVL 43

Accepted Solution

by:
Rob earned 500 total points
ID: 40545824
Please check the console in your developer tools as it could be a cross origin issue

open your developer tools and see the error that appears in the console.
http://jsbin.com/yeyote/1/edit?js,console
0
 
LVL 1

Author Comment

by:JElster
ID: 40545834
Don't see anything in the console.. I see this.. I need it in Angular.
??

(function() {
  var uri = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/93930/catalog.json";
  $.ajax({
    url: uri,
    dataType: 'json',
    success: function(data) {
      console.log(data);
    }
  }).done(function() {
    console.log('hi');
  });
});
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question