Reputation: 23
I'm just wondering how to use routeParams
correctly.
I wrote code like this in app.js:
.when('/product', {
templateUrl: 'views/product.html',
controller: 'ProductController',
title: ''
})
.when('/product/:productId', {
templateUrl: 'views/product_detail.html',
controller: 'ProductDetailController',
title: ''
})
.when('/product/new', {
templateUrl: 'views/product_new.html',
controller: 'ProductController',
title: ''
})
Here's the thing: I want to use URI named '/product/new'
but it goes '/product/:productId'
.. (product_detail.html
)
I want to how to use '/product/:productId'
and '/product/new'
both.
Is there any way to route like that?
Upvotes: 2
Views: 39
Reputation: 5466
Change the order in which you do routing to:
.when('/product', {
templateUrl: 'views/product.html',
controller: 'ProductController',
title: ''
})
.when('/product/new', {
templateUrl: 'views/product_new.html',
controller: 'ProductController',
title: ''
})
.when('/product/:productId', {
templateUrl: 'views/product_detail.html',
controller: 'ProductDetailController',
title: ''
})
Upvotes: 2