是我的$stateProvider:
$stateProvider
.state('home', {
url : '/',
templateUrl : '/admindesktop/templates/main/',
controller : 'AdminDesktopMainController'
}).state('company', {
url : '/company',
templateUrl : '/admindesktop/templates/grid/',
controller : 'CompanyGridController'
}).state('company.detail', {
url : '/{id:\d+}', //id is
templateUrl : '/admindesktop/templates/company/detail/',
controller : 'CompanyDetailController'
});它适用于'company‘状态(我使用ui-sref),但此代码不起作用(从'company’状态调用):
$state.go('.detail', {
id: $scope.selectedItem.id //selectedItem and id is defined
});我阅读了StackOverflow的官方文档和答案,但我没有找到解决方案。我不能使用ui-sref,我使用ui-grid,并在从表中选择一行进行编辑后打开新的状态。
我做错了什么?
发布于 2015-01-20 18:11:58
始终有效的是完整的状态定义:
// instead of this
// $state.go('.detail', {
// use this
$state.go('company.detail', {
id: $scope.selectedItem.id //selectedItem and id is defined
});在doc there are defined these options中,但它们依赖于当前状态:
to字符串
绝对状态名称或相对状态路径。下面是一些例子:
发布于 2015-01-20 18:35:37
我的错误是在正则表达式中,真的:
.state('company.detail', {
url : '/{id:\d*}',
templateUrl : '/admindesktop/templates/company/detail/',
controller : 'CompanyDetailController'
}){id:\d*}有效(整数id)。
发布于 2020-07-21 21:12:20
要加载当前状态,请执行以下操作。看看这个。
$state.go($state.current, {}, {reload: true}); //second parameter is for $stateParamshttps://stackoverflow.com/questions/28042598
复制相似问题