My AngularJS application has routes that can be either:
www.website.com/blog/xyz
www.website.com/blog/xyz/title/other-params
In the second URL, the title parameter is used for readability purposes only and is not mandatory in the URL. Therefore, I have implemented the following AngularJS code for my routes:
$routeProvider
.when('/blog', {
templateUrl : url,
controller : 'blogsHome'
})
.when('/blog/:blog_id', {
templateUrl : url,
controller : 'blogInfo'
})
.when('/blog/:blog_id/:url_params*', {
templateUrl : url,
controller : 'blogInfo'
});
In the above code, I had to include a middle when statement because Angular requires the :url_params
parameter and it cannot be empty. Is there a way to avoid having this extra middle when statement?