根据特定登录 ID 显示按钮

Showing button based of specific log in id

目前,如果用户未登录,我可以隐藏该按钮,当用户使用 html 页面中的 ng-show 标签登录时,它会显示。但我想要的是仅当用户使用特定登录 ID 登录时才显示的按钮。例如:ng-show="currentUser" 其中电子邮件 == example01@gmail.com 或 currentUser==example01@gmail.com。我不太确定这是如何工作的,但我该怎么做呢?

登录功能

    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>

这应该有效:currentUser==example01@gmail.com 但不是将电子邮件放入 DOM 的最佳方式。您还可以使用检查特定用户是否登录的功能,例如:

ng-show="checkCurrentUser()"

$rootScope.checkCurrentUser = function () {
    $rootscope.currentUser == example01@gmail.com ? return true : return false;
}

这样做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>