我一直在使用 Kinvey HTML5 库来尝试构建一个使用 Google 身份登录的客户端应用程序。就 Oauth 事务而言,一切似乎都很好,但我正在尝试使用范围参数和在 Kinveyconnect方法的回调中切换登录按钮的可见性,Angular 似乎没有检测到更改.
服务:
  connect: function(successFn, failureFn) {
    return Kinvey.Social.connect(null, 'google',
      {
        success: successFn,
        failure: failureFn
      });
  }
登录链接的指令:
    $scope.login = function() {
      Login
        .connect(function(response) {
          $scope.loggedIn = true;
        },
        function(response) {
        });
    }
和指令模板:
<div>
  <button ng-hide="loggedIn" type="button" class="btn" ng-click="login()">Login with Google ({{loggedIn}})</button>
  <div class="btn-group btn-small" ng-show="loggedIn">
    <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
      Hello, {{user.socialData.name}} <span class="caret"></span>
    </a>
    <ul class="dropdown-menu">
      <li><a href="/profile">My Profile</a></li>
      <li><a href="/performance">My Performance</a></li>
      <li class="divider"></li>
      <li><a href="/logout" ng-click="logout()">Log Out</a></li>
    </ul>
 </div>
</div>
目标是切换登录按钮的可见性与下拉菜单的可见性。我看不出为什么我正在做的事情不应该奏效。即使使用$timeout模拟loggedIn值的变化也会产生正确的行为。