app.js
.state('stats',{
url:'/stats/:id',
//abstract : true,
controller : 'statsController'
//controllerAs: 'statsDetails',
//templateUrl : 'app/templates/statsDetails.html'
})
.state('details',{
url : '',
controller : 'statsController'
//name : 'stats'
//templateUrl : 'app/templates/statsDetails.html'
})
statsController.js
app.controller('statsController',function($scope,$state,StatsFactory){
//FOR PARENT STATE CALL GET BASIC DETAILS
if($state.current.name == "stats"){
$scope.id_campaign = $state.params.id;
StatsFactory.getOptCampaign($scope.id_campaign).then(function(data) {
$scope.OptCampaignDetail = data.data[0];
StatsFactory.getRemList($scope.OptCampaignDetail.key_campaign)
.then(function(data){
$scope.remList = data.data;
$state.go('details'); //cannot use getAll
console.log($state);
});
});
}
//FOR AL DETAILS WITH REMUNARETION LIST
if($state.current.name == 'details'){
console.log($state.current.name);
console.log($scope.remList);
}
});
在'详细信息'状态内我无法获得父范围变量。我尝试使用抽象状态但无法访问$ scope.remList。请给我一些建议我今天早上堆叠。顺便说一下,我新的角度
答案 0 :(得分:0)
如果您只想要数据,可以通过$ state.go传递数据:
$state.go('details', {remList: $scope.remList});
在你的app.js中:
.state('stats',{
url:'/stats/:id',
//abstract : true,
controller : 'statsController'
//controllerAs: 'statsDetails',
//templateUrl : 'app/templates/statsDetails.html'
})
.state('details',{
url : '',
controller : 'statsController',
params: {remList: null} //default param
//name : 'stats'
//templateUrl : 'app/templates/statsDetails.html'
})
您可以稍后使用$ stateParams.remList访问它。