hi working on my first angular project and i've run into this problem with not being able to see a value from the service im using in one of my controllers.
also the characterService.query() is fine just the value of errorMessage is not showing up
thanks for your help
Service:
angular.module('characterResource',['ngResource'])
.factory('characterService',['$resource',function($resource){
var self = this;
self.errorMessage = false;
return $resource('http://gateway.marvel.com:80/v1/public/characters?limit=90&apikey=APIKEY',null, {
query: {
method: 'GET',
isArray: false,
transformResponse: function(data) {
return angular.fromJson(data).data;
},
interceptor:{
responseError:function(error){
console.log(error);
self.errorMessage = true;
}
}
}
});
}]);
controller:
angular.module('CharactersCtrl', []).controller('CharactersController',['characterService', function(characterService) {
var self = this;
self.sortType = 'name'; // set the default sort type
self.sortReverse = false; // set the default sort order
//self.search = ' '; // set the default search/filter term
self.errorMessage = characterService.errorMessage;
console.log(characterService.errorMessage);
self.init = function(){
self.getCharacters();
}
self.getCharacters = function(){
self.characters = characterService.query();
}
self.init();
}]);