gpt4 book ai didi

angularjs - 如何 $state.go()

转载 作者:行者123 更新时间:2023-12-03 15:56:34 24 4
gpt4 key购买 nike

是我的 $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'
});

它适用于“公司”状态(我使用 ui-sref),但此代码不起作用(从“公司”状态调用):
$state.go('.detail', {
id: $scope.selectedItem.id //selectedItem and id is defined
});

我从 StackOverflow 阅读了官方文档和答案,但没有找到解决方案。我无法使用ui-sref,我使用ui-grid,并且在从表中选择一行进行编辑后打开了新状态。

我做错了什么?

最佳答案

始终有效的是完整的状态定义:

// 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 string
Absolute state name or relative state path. Some examples:

  • $state.go('contact.detail') - will go to the contact.detail state
  • $state.go('^') - will go to a parent state
  • $state.go('^.sibling') - will go to a sibling state
  • $state.go('.child.grandchild') - will go to grandchild state

关于angularjs - 如何 $state.go(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28042598/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com