【问题标题】:Iconic ion-nav-view dont change after change the URL更改 URL 后 Ionic ion-nav-view 不会更改
【发布时间】:2015-03-29 14:19:58
【问题描述】:

我正在尝试在 Ionic 中创建身份验证页面。登录正在工作,当我按下登录时,视图更改为 ion-tab。但是当我按“没有帐户?”时ion-nav-view 不会更改内容(URL 正在从 /#/login 更新为 /#/login/create)。我做错了什么?

index.html

...
<ion-nav-view></ion-nav-view>
...

app.js

...
.config(function($stateProvider, $urlRouterProvider) {    
$stateProvider

.state('auth', {
    url: "/login",
    views: {
      '': {
        templateUrl: 'templates/auth-login.html',
        controller: 'AuthLoginCtrl'
      }
    }
  })

.state('auth.create', {
    url: "/create",
    views: {
      'authcreate': {
        templateUrl: 'templates/auth-create.html',
        controller: 'AuthCreateCtrl'
      }
    }
  })
 ...

登录页面

...
<button class="button button-clear button-block button-assertive" ui-sref="auth.create">
 Don't have an account?
</button>
...

auth-create.html

<ion-view title="Create">
    <ion-content class="padding">
        <h1>Create</h1>
    </ion-content>
</ion-view>

【问题讨论】:

    标签: angularjs routes ionic-framework


    【解决方案1】:

    这看起来不对...

    .state('auth.create', {
        url: "/create",
        views: {
          'authcreate': { // <=== remove this
            templateUrl: 'templates/auth-create.html',
            controller: 'AuthCreateCtrl'
          }
        }
      })
    

    我也认为你的路由结构不正确,我不知道你为什么这样做登录视图;我的结构是这样的。

    // create account state
    .state('app-signup', {
        url: "/signup",
        templateUrl: "templates/user/signup.html",
        controller: "SignUpController"
    })
    // login state that is needed to log the user in after logout
    // or if there is no user object available
    .state('app-login', {
        url: "/login",
        templateUrl: "templates/user/login.html",
        controller: "LoginController"
    })
    

    在此处查看完整的应用程序 - https://github.com/aaronksaunders/dcww

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-11
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 2017-04-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多