【发布时间】:2015-01-20 06:11:56
【问题描述】:
这当然行不通,但应该解释我想要实现的目标:
在工厂 "myapp.factory('gameService', function($http, $location) {" 我从 json feed 加载数据 "return $http.jsonp('api/game/' + id + '?callback=JSON_CALLBACK')",如果没有加载数据,将最初加载的templateURL改为404页面url。
var get_data = function (id) {
return $http.jsonp('api/game/' + id + '?callback=JSON_CALLBACK')
.then(function(response) {
//data loaded, do magic
}, function(response) {
//data not loaded
templateUrl: 'views/page_not_found.html'; //<- how to inject this so it works?
});
};
【问题讨论】:
标签: javascript angularjs