How to change side menu in ionic for a loggedin user

前端 未结 1 1221
说谎
说谎 2021-01-12 10:00

I want to change content of side menu when a user is logged in.

Example 1 - user not logged in:

This side menu is shown when a user isn\'t l

相关标签:
1条回答
  • 2021-01-12 10:11

    you can put ng-if OR ng-show and ng-hide.. i have used ng-if..!

    in menu controller:

    .controller('AppCtrl', function($scope, $ionicModal, $timeout,$ionicSideMenuDelegate,$http) {
    
    $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));
        if(result.data.prenom) {
          $scope.prenomconsommateurConnect = result.data.prenom;
        }else{
          $scope.prenomconsommateurConnect = "";
        }
    });
    
    $scope.$watch(function () {
      return $ionicSideMenuDelegate.getOpenRatio();
    }, function (value) {
      console.log("value " + value);
      $scope.getMenuProfile();
    });
    
    $scope.getMenuProfile = function () {
      if($scope.prenomconsommateurConnect === "" ){
        $scope.isLogin =false ;
      }else{
        $scope.isLogin =true ;
      }
    };
    }
    

    menu.html

    <ion-header-bar class="bar-stable">
      <h1 ng-if="!isLogin" class="title">Login plz</h1>
      <h1 ng-if="isLogin"  class="title">U are Login</h1>
    </ion-header-bar>
    

    hope this helped you.

    0 讨论(0)
提交回复
热议问题