[英]How to attach the controller $scope variable to $state data in ui-router?
在我的代碼中,我想將$ scope.requireLogin值附加到數據的requireLogin 。 我怎么能在這個.state
得到這個?
.state('403', {
url: '/403',
templateUrl: '403.tmpl.html',
controller: function($scope, $state, APP, Auth) {
$scope.app = APP;
$scope.goHome = function() {
if(Auth.isAuthenticated()){
$scope.requireLogin = true;
$state.go('admin-panel.default.home');
}
else{
$scope.requireLogin = false;
$state.go('admin-panel.public.home');
}
};
},
data: {
requireLogin: $scope.requireLogin
}
})
誰能告訴我方法嗎?
您可以在控制器中進行操作。
$state.current.data.requireLogin =$scope.requireLogin;
而不是數據屬性。 使用參數,如params:{theKeyIWantToUse:null}轉到下一個狀態時,請使用$ state.go(“ blaroute”,{theKeyUsedInParams:theValue},然后使用$ stateParams.theKeyUsedInParams來獲取值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.