我有一个父状态app.teams.show,它将“team”存储在$ scope.data.team中。在控制器中,我可以访问$ scope.data.team,因此可以访问$ scope.data.team.organization_id。
如何在解析中访问$ scope.data.team.organization_id?
.state('app.teams.show.games.add', {
url: '/add',
templateUrl: 'templates/schedule/games/add.html',
controller: 'GamesAddCtrl',
resolve:{
org: function($http, $scope){
return $http.get('http://api.example.com/orgs/'+$scope.data.team.organization_id, {cache: true});
}
}
})
答案 0 :(得分:0)
我认为你想要达到的目标是正确的解决方案
在您的情况下,我可能只会将$scope.data.team.organization_id
作为参数传递给您的状态并在解析块中使用它。
.state('app.teams.show.games.add', {
url: '/add/:orgId', // or /add?orgId or :orgId/add
templateUrl: 'templates/schedule/games/add.html',
controller: 'GamesAddCtrl',
resolve:{
org: function($http, $stateParams){
return $http.get('http://api.example.com/orgs/'+$stateParams.orgId, {cache: true});
}
}
})