Answer the question
In order to leave comments, you need to log in
Templates for authorized users and not authorized?
I am writing a website in Angular. Wrote a simple authorization. I have a side menu (like enter/register), which should disappear and another one should appear, there is a user authorized. So what's the best way to do this?
Not only is the menu supposed to change like this...
And one more thing:
How to configure the Apache server to work with Angular?
Thanks in advance)
Answer the question
In order to leave comments, you need to log in
When starting the application, do this:
angular
.module('App')
.run(['$rootScope', 'authFactory', function ($rootScope, authFactory){
$rootScope.isAuth = function () {
return authFactory.SessionState(); // в методе проверяем состояние сессии, например наличие нужных кукисов или данных в локалсторадж, и возвращаем true или false
}
}]);
li(ng-if='!isAuth()')
a(ui-sref='login')
span.glyphicon.glyphicon-lock
| Вход
li(ng-if='isAuth()')
a(ng-click='logOut()')
span.glyphicon.glyphicon-log-out
| Выход
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question