使用ui-router。看看这个。 从控制器开始:
$scope.transitionResponse = {};
$scope.hello= "world";
transition.makeTransitionCashOutCall(strippedUrl).then(function(response){
//nested view will need this to build out layout
$scope.transitionResponse.OnlineDistributionProcessUrl = response.data.OnlineDistributionProcessUrl;
console.log(response);
console.log($scope.transitionResponse.OnlineDistributionProcessUrl);
if(!response.data.OnlineDistributionProcess){
$scope.showDocument(transitionType);
}else{
//display phone no. if no url
$state.go('rollover-options.cashout-info');
//display url if it exists (same view ^)
}
});
$ scope.transitionResponse.OnlineDistributionProcessUrl的console.log给了我正确的值。但是当我深入到另一个状态时,值会丢失,并且我在console.logs或alert上得到了未定义。到底是怎么回事?真?为什么价值集会丢失?我可以在cashout-info视图中使用{{hello}}访问硬编码值,例如$ scope.hello。但另一个价值正在迷失。我真的迷失了。
答案 0 :(得分:0)
你还没有在json
中声明这个字段的OnlineDistributionProcessUrl$scope.transitionResponse = {};
instead it should be like this
$scope.transitionResponse={
"OnlineDistributionProcessUrl":null
}
or you can use
$scope.transitionResponse['OnlineDistributionProcessUrl'] = response.data.OnlineDistributionProcessUrl;