Created
January 13, 2017 18:18
-
-
Save lvidal1/8b852415f838a3e114fa62481415443f to your computer and use it in GitHub Desktop.
Angular - Check if template exist on $routeProvider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$routeProvider.when("/resource/:slug", { | |
controller: "ResourceController", | |
resolve: { | |
check: ["$route", "$http", "$location", function($route, $http, $location){ | |
return $http.get("/views/" + $route.current.params.slug + ".html").success(function(res){ | |
return true; | |
}).error(function(res){ | |
return $location.path("/"); | |
}); | |
}] | |
}, | |
template: function($routeParams){ | |
return '<div id="project" ng-include="\'/views/' + $routeParams.slug + '.html\'"></div>'; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment