ui-router-metatags
Advanced tools
Changelog
0.0.4
Added prerender status code and header.
When an stateChangeError or a stateNotFound event is thrown, the status is set automatically (to 500 and 404 respectively), but it also offers manual control if needed.
function configureRoutes($stateProvider) {
$stateProvider
.state('blogposts', {
url: '/blog/:category',
resolve: {
/* @ngInject */
posts: function(myService, $stateParams) {
return myService.getPosts($stateParams.category);
}
}
metaTags: {
prerender: {
/* @ngInject */
statusCode: function(posts) {
return posts.length > 0 ? 200 : 302;
},
/* @ngInject */
header: function(posts) {
return posts.length > 0 ? null : 'Location: http://example.com/posts';
}
}
}
});
}
angular
.module('myApp')
.config(configureRoutes);
In the example above, if there are posts, then a status code of 200 is returned, whereas if no posts are there, then a 302 is set and a redirect location is offered.