Is it possible to modify the side menu content based on whether a user is logged in or not?
Example 1 - user not logged in:
If a user isn't logged in, this side menu will be displayed.
https://i.stack.imgur.com/iY427.png
Example 2 - user is logged in:
When a user is logged in, additional menu items are shown. These extra items are visible only for logged-in users.
https://i.stack.imgur.com/cRhp8.png
In my controller:
$http.get('http://127.0.0.1:8080/elodieService/consommateurs/'+$localStorage.idconsommateur, { params: { "idconsommateur":$localStorage.idconsommateur, fields: "nom,prenom",format:"json"} }).then(function(result) {
console.log(JSON.stringify(result.data));
$scope.prenomconsommateurConnect=result.data.prenom;
In the view :
<ion-header-bar class="bar-stable" >
<h1 class="title" ng-hide="!prenomconsommateurConnect" ng-controller="accueilController">Bonjour Hello {{prenomconsommateurConnect}}</h1>
<h1 class="title" ng-hide="prenomconsommateurConnect" ng-controller="accueilController">Bonjour Hello link</h1>
</ion-header-bar>
However, I always see the result as "bonjour hello link". How can I fix this issue?
What approach should I take? Should I consider using ng-if
, ng-show
, or ng-hide
? Or perhaps there is a better solution for this scenario?
Any assistance would be greatly appreciated.