我想在成功登录后重定向到主页。直到那时我想要一个只有登录屏幕的空白页面。
目前它在成功登录后重定向但我需要一种方法来禁用菜单栏并只显示登录页面直到登录i。
我有一个路由提供商,其代码如下: -
.when("/login", {
templateUrl : "../view/login.html",
controller : "loginController"
}).otherwise({
redirectTo:'/'
});
我能够成功加载登录页面。验证成功后,它将重定向到所需的页面。
控制器代码如下: -
$scope.validUser = function(){
if($scope.username != $scope.password)
{$scope.message = "authentication unsuccessful, Please try again!";}
else
{$scope.message = "authentication successful, You will now be redirected
in 5 seconds";
$timeout(function() {
$location.path('/');
}, 5000);
}
}
首页代码:
<body>
<!-- Fixed navbar -->
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-
toggle="collapse" data-target="#navbar" aria-expanded="false" aria-
controls="navbar">
<span class="sr-only">Toggle navigation</span> <span
class="icon-bar"></span> <span class="icon-bar"></span>
<span
class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">EHS-Analytics</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="dropdown" uib-dropdown>
<a href="" id="overviews" class="dropdown-toggle" uib-
dropdown-toggle aria-haspopup="true" aria-expanded="false">
Overviews <span class="caret"></span>
</a>
<ul class="dropdown-menu" uib-dropdown-menu aria-
labelledby="overviews">
<li><a href="#!uploadData">Upload Data</a></li>
</ul>
</li>
<li class="dropdown" uib-dropdown>
<a href="" id="goals" class="dropdown-toggle" uib-
dropdown-toggle aria-haspopup="true"
aria-expanded="false">Goals <span class="caret"></span>
</a>
<ul class="dropdown-menu" uib-dropdown-menu aria-
labelledby="goals">
<li><a href="#">Goal Builder</a></li>
<li><a href="#">Customize Goal</a></li>
</ul></li>
<li class="dropdown" uib-dropdown>
<a href="" id="measures" class="dropdown-toggle" uib-
dropdown-toggle aria-haspopup="true"
aria-expanded="false">Measures <span class="caret">
</span></a>
<ul class="dropdown-menu" uib-dropdown-menu aria-
labelledby="measures">
<li><a href="#">Add new</a></li>
</ul></li>
<li class="dropdown" uib-dropdown>
<a href="" id="forecasting" class="dropdown-toggle" uib-
dropdown-toggle aria-haspopup="true"
aria-expanded="false">Forecasting <span class="caret"></span></a>
<ul class="dropdown-menu" uib-dropdown-menu aria-labelledby="forecasting">
<li><a href="#">Create New</a></li>
</ul></li>
<li><a href="#about">Report</a></li>
<li><a href="#contact">Administration</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown"><a href="#" class="dropdown-toggle"
data-toggle="dropdown" data-ng-model = "Dropdown"
role="button" aria-haspopup="true"
aria-expanded="false">{{username}} <span class="caret">
</span></a>
<ul class="dropdown-menu">
<li><a href="#">View Profile</a></li>
<li><a href="#">Change Password</a></li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">More</li>
<li><a href="#!login" >login</a></li>
<li><a href="#!LogOut" type = "button" data-ng-
click= "showAlert()">LogOut</a></li>
</ul></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</nav>
答案 0 :(得分:0)
试试这个
$scope.shownav = true;
$scope.validUser = function(){
if($scope.username != $scope.password)
{$scope.message = "authentication unsuccessful, Please try again!";}
else
{$scope.message = "authentication successful, You will now be redirected
in 5 seconds";
$scope.shownav = false;
$timeout(function() {
$location.path('/');
}, 5000);
}
}
然后在html上
<nav class="navbar navbar-inverse navbar-fixed-top" ng-if="shownav">
答案 1 :(得分:0)
在您的login.html的标记中,输入&#39; hide-nav-bar =&#34; true&#34;隐藏回按钮=&#34;真&#34;&#39;
<ion-view title="Login" hide-nav-bar="true" hide-back-button="true"></ion-view>
还将其放入您的登录控制器:
$ionicSideMenuDelegate.canDragContent(false);
不要忘记在控制器中包含$ ionicSideMenuDelegate。