I use Angular UI router and have defined the following state:
$stateProvider.state('objectDetails', {
url: '/object/:type/:id',
templateUrl: 'url/to/my/template.html',
controllerProvider: function($stateParams) {
capitalized = $stateParams.type.charAt(0).toUpperCase() + $stateParams.type.substr(1)
return capitalized + 'DetailsController'
}
});
When I enter the /object/flower/123
I expect the controller of the view to be FlowerDetailsController
etc. It works.
Question is how to handle an error (invalid object type in an url). I.e. the WeedDetailsController
does not exist and when I enter the /object/weed/123
, the error is being thrown.
How the controller provider is supposed to notify UI router that it can not provide any controller for given params? I would expect the router to display $urlRouterProvider.otherwise
path, which I specified with nice 404 error.