我只想在登录成功时打开页面, 我在控制器中使用了标志,我也想在app.js中显示。如何从angularjs中的app.js中的控制器定义一个变量?
headerCtrl.js:
$scope.verifyOTP = function(mobileNumber,otpNumber) {
$rootScope.UserAuthorised=false;
$http.get($scope.url,config).success(function(data, status) {
$rootScope.UserAuthorised=true;
$window.alert("Login Successfully!! ");
var Mypath = '/home' ;
$location.path(Mypath);
$location.replace();
})
}
App.js:
if($rootScope.UserAuthorised==true){
adminApp.config(function($routeProvider) {
$routeProvider
.when('/home', {
templateUrl : 'pages/credentials/registration.html',
controller : ''
})
})
}
如何定义我的变量从控制器到app.js,这样我可以从真正改变我的标志设置为false反之亦然。 任何帮助表示赞赏。 感谢
不知道你正在努力实现......如果验证客户端使用'resolve'财产在你的路由配置是什么? – kukkuz