I know I am suppose to do and ng-hide="something", but I don't where to go from there. Not sure if I have to also write another function in my logoutController or mainController.
<ul class="right hide-on-med-and-down">
<li><a ui-sref="login">Login</a></li>
<li><a ui-sref="logout" ng-click='logoutCtrl.logout()'>Logout</a></li>
</ul>
</div>
nav.html
function logoutController($state, AuthService) {
var vm = this
vm.logout = function () {
// call logout from service
AuthService.logout()
.then(function () {
$state.go('login')
})
} }
app.js
It depend the way you're login works but you can do
<ul class="right hide-on-med-and-down">
<li><a ng-show="inNotLogged"ui-sref="login">Login</a></li>
<li><a ui-sref="logout" ng-click='logoutCtrl.logout()'>Logout</a></li>
</ul>
</div>
and in your app.js .run
set $rootScope.isNotLogged = true;
then in your login method:
$rootScope.isNotLogged = false;
$scope.isNotLogged = $rootScope.isNotLogged;
so in tour lgout you will set
$scope.isNotLogged = true;
$rootScope.isNotLogged = $scope.isNotLogged;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.