0
我正在使用angularjs-ui router模块来管理我的状态。AngularJs UI路由器URL格式化
我有这样的结构:
$stateProvider.state('menu', {
templateUrl: '/templates/menu/wrap.html',
params: {
slug: {
value: ''
},
id: {
value: null
}
},
ncyBreadcrumb: {
label: 'Menu'
}
}).state('menu.list', {
url: '/:slug',
parent: 'menu',
params: {
slug: {
value: ''
},
id: {
value: null
},
Name: {
value: '{{Name}}'
},
Type: {
value: null
}
},
views: {
// the main template will be placed here (relatively named)
'': {
templateUrl: '/templates/menu/main.html',
controller: 'MenuMainCtrl as MNC'
},
// for column two, we'll define a separate controller
'[email protected]': {
templateUrl: '/templates/menu/productlist.html',
controller: 'ProductListCtrl as PLC'
},
// for column two, we'll define a separate controller
'[email protected]': {
templateUrl: '/templates/menu/navigation.html',
controller: 'MenuNavigationCtrl as MN'
},
// for column two, we'll define a separate controller
'[email protected]': {
templateUrl: '/templates/menu/cart.html',
controller: 'CartCtrl as CC'
}
},
ncyBreadcrumb: {
label: '{{Name}}'
}
}).state('menu.detail', {
parent: 'menu.list',
url: '/:productSlug',
params: {
productID: {
value: ""
},
productSlug: {
value: ""
},
productName: {
value: ""
},
Name: {
value: "Breakfast"
},
Type: {
value: null
},
MenuListItemID: {
value: null
}
},
views: {
'@': {
templateUrl: '/templates/menu/productSingle.html',
controller: 'ProductSingleCtrl as PSC'
}
},
ncyBreadcrumb: {
label: '{{productName}}'
}
});
见名为 “menu.detail” 最后的状态。这个的基本URL是“/ menu /”,当这个状态激活时,我的URL是例如。 “localhost:8081/menu/breakfast-sandwiches/farmtotable-breakfast-sandwiches”但我的客户想要成为“localhost:8081/product/farmtotable-breakfast-sandwiches”。
这是甚至可能的,如果是,你能帮我吗?
我更新了“URL”键,现在的状态仍然工作,但URL是“本地主机:8080 /菜单/产品/经典午餐签名” 。看到这个“/菜单/”我想摆脱那和URL是“本地主机:8080 /产品/经典午餐签名”@abhim – SempachoO
我使它的工作。我只是将我的“ ”更改为“ ”,并用一个小小的推文来表现它的魅力。 –
SempachoO