Can I set a route with optional params (same template and controller, but some params should be ignored if they don't exist?
So instead of writing the following two rules, have only one?
module.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/users/', {templateUrl: 'template.tpl.html', controller: myCtrl}).
when('/users/:userId', {templateUrl: 'template.tpl.html', controller: myCtrl})
}]);
Something like this ([this param is optional])
when('/users[/:userId]', {templateUrl: 'template.tpl.html', controller: myCtrl})
//note: this previous doesn't work
I couldn't find anything in their documentation.
[]
) in 1.1.5 version. – Blandishment[]
. See this commit: github.com/angular/angular.js/commit/… – Blandishment