更改状态时,ion-view不会更新

时间:2016-01-24 18:27:15

标签: angularjs login ionic-framework

我试图在Ionic中创建一个简单的登录系统。当我输入我的凭据并点击登录时,它应该带我进入设置屏幕。它这样做,但它没有更新标题;它仍然说帐户 - 它应该说设置。

设置视图:

 <ion-view view-title = "Settings">
         <ion-nav-buttons side="primary">
            <button class="button button-full button-assertive" style = "margin-top: 0px;" ng-click = "signOff()">
              Log Off
            </button>
          </ion-nav-buttons>
        <ion-content class="has-header padding">
            ...
            ...
            ...
  </ion-content>
</ion-view>

帐户视图:

 <ion-view view-title="Account">
             <ion-nav-buttons side="primary">
                <button class="button button-full button-assertive" style = "margin-top: 0px;" ng-click = "signOff()">
                  Log Off
                </button>
              </ion-nav-buttons>
      <ion-content class = "padding">
            <div class="list">
          <label class="item item-input">
            <span class="input-label">Username</span>
            <input type="text" ng-model = "userName">
          </label>
          <label class="item item-input">
            <span class="input-label">Password</span>
            <input type="password" ng-model = "password">
          </label>

          <button style = "margin: 10px"; class="button button-positive"; ng-click = "logIn(userName, password)">
            Log in
          </button>

          <button style = "margin: 10px"; class="button button-positive"; ng-click = "createAccount(userName, password)">
            Create Account
          </button>

        </div>

      </ion-content>
    </ion-view>

tabs.html:

<ion-tabs class="tabs-icon-top tabs-color-active-positive">

  <!-- Dashboard Tab -->
  <ion-tab title="Status" icon-off="ion-ios-pulse" icon-on="ion-ios-pulse-strong" href="#/tab/dash">
    <ion-nav-view name="tab-dash"></ion-nav-view>
  </ion-tab>

  <!-- Chats Tab -->
  <ion-tab title="Chats" icon-off="ion-ios-chatboxes-outline" icon-on="ion-ios-chatboxes" href="#/tab/chats">
    <ion-nav-view name="tab-chats"></ion-nav-view>
  </ion-tab>

  <!-- Account Tab -->
  <ion-tab title="Account" icon-off="ion-ios-gear-outline" icon-on="ion-ios-gear" href="#/tab/account">
    <ion-nav-view name="tab-account"></ion-nav-view>
  </ion-tab>

  <ion-tab title="Settings" hidden="true">
      <ion-nav-view name="tab-settings"></ion-nav-view>
  </ion-tab>

</ion-tabs>

登录功能:

  $scope.logIn = function(userName, password) {
    console.log(userName);
    console.log(password);
      $rootScope.ref.authWithPassword({
        email    : userName,
        password : password
      }, function(error, authData) {
        if (error) {
          console.log("Login Failed!", error);
        } else {
          console.log("Authenticated successfully with payload:", authData);
          $rootScope.isLoggedIn = true;
          $state.go('tab.settings');
         // $window.location.href = "#/tab/settings";
        }
      });
  };

我尝试过$ window.location.href而不是$ state.go,我试图在离子视图中使用ion-nav-title,但两者仍然产生相同的结果。

有什么想法吗?

先谢谢!

编辑:看起来它也使用帐户控制器而不是设置控制器。

0 个答案:

没有答案