Hi! I have the following code and gives me an error:
I have the following code and gives me an error:
app.factory('buscarnoticias',function($http){
return{
noticiajson: function(){
var url = "xxxxx?callback=JSON_CALLBACK";
$http.get(url)
.success(function(data){
return data;
});
}
}
});
app.service('ultimasService', function($q,buscarnoticias) {
return {
noticias: function(){
var datos = buscarnoticias.noticiajson();
return datos;
},
GetNoticias: function() {
return this.noticias();
},
GetNoticia: function(noticiaId) {
var dfd = $q.defer()
this.noticias().forEach(function(noticia) {
if (noticia.id === noticiaId) dfd.resolve(noticia);
});
return dfd.promise;
}
}
});
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('app.ultimasNoticias', {
url: "/ultimasNoticias",
views: {
'menuContent' :{
templateUrl: "templates/ultimasNoticias.html",
controller: 'ultimasCtrl',
resolve: {
noticias: function(ultimasService) {
return ultimasService.GetNoticias()
}
}
}
}
})
.state('app.ultimasNoticiasDetail', {
url: "/ultimasNoticiasDetail/:noticiaId",
views: {
'menuContent' :{
templateUrl: "templates/ultimasNoticiasDetail.html",
controller: 'ultimasDetailCtrl',
resolve: {
noticia: function($stateParams, ultimasService) {
return ultimasService.GetNoticia($stateParams.noticiaId)
}
}
}
}
});
$urlRouterProvider.otherwise('/app/ultimasNoticias');
});
Error:
The page is blank