我只是想知道如何正确使用routeParams
。
我在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: ''
})
事情是这样的:我想使用名为 '/product/new'
的 URI
但它是 '/product/:productId'
.. (product_detail.html
)
我想知道如何同时使用 '/product/:productId'
和 '/product/new'
。
有没有办法这样路由?
最佳答案
将路由顺序更改为:
.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: ''
})
关于angularjs - 如何正确使用angularjs的routeParams,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30883107/