Reputation: 9678
I'm trying to follow along a AngularJS tutorial about making a Email Client.
I downloaded the source code with all chapters from 01 to 07. Started my own project in a folder called "Application".
The code is running without throwing any errors, but the thing is that it's the wrong JSON file that is being loaded!
I copied the json from 04 and changed the first from
to be Hello World
(originally TicketFactory
). Changed every others json files to contain their location, so chapter 04 became TicketFactory chapter 04
and so on.
Now starting the server in the Application
directory gives me this:
I have no clue where it is getting this .json file..? Perhaps an old GET request?
My code looks like this
InboxFactory.js
(function() {
'use strict';
angular
.module('EmailApp')
.factory('InboxFactory', myfactory);
myfactory.$inject = ['$q','$http', '$location'];
function myfactory($q, $http, $location){
var exports = {};
exports.getMessages = function () {
return $http.get('json/emails.json')
.error(function(data) {
console.log('There was an error!', data);
});
};
return exports;
}
})();
It might look a bit different from the tutorial because I used Atom's AngularJS snippet package. But it looks good enough for me, but then again - I'm still learning!
Upvotes: 0
Views: 166
Reputation: 1323
It also could be a cache problem !
Do F12, and check the "Network" tabs (with an F5...): you will retry the full path of the file, it's contents,...
Upvotes: 1
Reputation: 1294
return $http.get('json/emails.json')
This is misleading because you have multiple json folders containing emails.json on your project root.
Try :
return $http.get('../Application/json/emails.json')
Upvotes: 0