如何正确使用angularjs routeParams
How to use angularjs routeParams properly
我只是想知道如何正确使用 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: ''
})
我只是想知道如何正确使用 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: ''
})