Still trying to learn Angular.
I have a plunker here - https://plnkr.co/edit/oEXn5JDKeqoN82jz3PC1?p=preview
Trying to load external json file using $http and $q
I have a simpleController calling a getJson() function in a simpleService file to load the json.
Just trying to output the data on the home page to start with.
Locally I'm getting an error in the console saying
TypeError: simpleService.getJson is not a function
The service
(function() {
angular.module('cxoAppJs').service('simpleService', simpleService);
simpleService.$inject = ['$http', '$q'];
function simpleService($http, $q) {
function getJson() {
var deferred = $q.defer();
http.get('https://api.myjson.com/bins/gznzh').then(function() {
deferred.resolve(data);
return deferred.promise;
})
}
}
})();