有角度的展示在报名后签字

时间:2016-03-08 18:25:57

标签: javascript angularjs

使用ng-token-auth进行角度身份验证。在注册之后,它没有显示注销按钮。但它适用于登录

我没有将它重定向到任何地方。此外,isLoggedIn(), signOut()函数可以正常工作。

我到底在哪里做错了?谢谢!

Navbar Controller

function($rootScope, $scope, $location, $auth, currentUser) {

  $scope.isLoggedIn = function() {
    return ($scope.user.id) ? true : false;
  }

  $scope.signOut = function() {
    currentUser.signOut();
  };

验证控制器

  $scope.submitRegistration = function() {
    $auth.submitRegistration($scope.registrationForm)
      .then(function(res) {
        currentUser.set(res.data.data);
        $scope.close();
      })
      .catch(function(res) {
        $scope.errors = res.data.errors.full_messages.join(', ');
      })
  };

  $scope.submitLogin = function() {
    $auth.submitLogin($scope.loginForm)
      .then(function(resp) {
        currentUser.set(resp);
        $scope.close();
      })
      .catch(function(resp) {
         $scope.errors = "Email or Password invalid...";
      });
  };

Navbar HTML

    <li ng-controller="AuthModalCtrl" ng-if='!isLoggedIn()'>
      <div ng-click="openModal(signin)">Sign In</div>
    </li>
    <li ng-controller="AuthModalCtrl" ng-if='!isLoggedIn()'>
        <div class="bubble-btn sign-up" ng-click="openModal('register')">Sign Up</div>
    </li>
    <li ng-controller="NavCtrl" ng-show='isLoggedIn()'>
       <div ng-click="signOut()">Sign Out</div>
    </li>

0 个答案:

没有答案