Search code examples
javascriptangularjsnode.jsstrongloop

Showing button based of specific log in id


For now, i am able to hide the button if the user is not logged in and it'll show when the user is logged in using the ng-show tag in html page. But what i want is the button to show only when the user logs in with a specific log in id. for example: ng-show="currentUser" where email == [email protected] or [email protected]. Im not really sure how this works but how do I do something like that?

log in function

    function login(email, password) {
  return User
    .login({email: email, password: password})
    .$promise
    .then(function(response) {
      $rootScope.currentUser = {
        id: response.user.id,
        tokenId: response.id,
        email: email
      };
    });
}

html

<button type="button" ng-show="currentUser" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#myModal">Send sms for selected </button>

Solution

  • Do it this way ng-show="(currentUser.id == '1234')":

        <button type="button" ng-show="(currentUser.id == '1234')" 
                    class="btn btn-primary btn-sm" data-toggle="modal" 
                    data-target="#myModal">Send sms for selected 
        </button>