Although this example may not function as intended, it serves to illustrate my goal:
Within the factory "myapp.factory('gameService', function($http, $location) {" I am retrieving data from a JSON feed by using "return $http.jsonp('api/game/' + id + '?callback=JSON_CALLBACK')". If the data fails to load, I want to switch the initially loaded templateURL to the URL for a 404 page.
var get_data = function (id) {
return $http.jsonp('api/game/' + id + '?callback=JSON_CALLBACK')
.then(function(response) {
//data successfully loaded, perform required actions
}, function(response) {
//data failed to load
templateUrl: 'views/page_not_found.html'; //<- How can I properly inject this so that it functions?
});
};