It's my first post on SO. Im trying Laravel-angular-material-starter (Lams) link and i have a problem with finding (in angular component) if user is authenticated. If he isen't i whant to show him login and register link. Lams us JWT Authentication. Thx for help !
In root-dir->angular->app->components->app-header->app-header.component.js i got :
class AppHeaderController{
constructor($log,$auth,$scope){
'ngInject';
this.$scope = $scope;
this.$log = $log;
this.$auth = $auth;
}
$onInit(){
//its not working
if(this.$auth==true){
this.$scope.zalogowany = true;
this.$log.log('yes');
}
else{
this.$scope.zalogowany = false;
this.$log.log('no');
}
}}
export const AppHeaderComponent = {
templateUrl: './views/app/components/app-header/app-header.component.html',
controller: AppHeaderController,
controllerAs: 'vm',
bindings: {} }
and in root-dir->angular->app->components->app-header->app-header.component.html i have :
<md-content class="Page-Container DemoHeader">
<div layout="row">
<div flex="90" flex-offset="5" class="DemoHeader-container">
<div layout="row" layout-align="space-between">
<a hide-xs class="DemoHeader-link md-subhead" href="#/" >DareMe</a>
<div layout="row" layout-align="center stretch">
<a ng-show="!zalogowany" hide-xs class="DemoHeader-link md-subhead" href="#/login" >Logowanie</a>
<a ng-show="!zalogowany" hide-xs class="DemoHeader-link md-subhead" href="#/register" >Rejestracja</a>
</div>
</div>
</div>
</div>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire