Saturday 29 April 2017

angular ui router - How to set mandatory route parameters

I want to make a route with has a mandatory parameter. If not, it should fall into



$urlRouterProvider.otherwise("/home");



Current route:




function router($stateProvider) {
$stateProvider.state("settings", {
url: "^/settings/{id:int}",
views: {
main: {
controller: "SettingsController",
templateUrl: "settings.html"
}
}
});

}


Currently both the routes below are valid:




  1. http://myapp/settings //Should be invalid route

  2. http://myapp/settings/123




Any ideas?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...