更改URL后,离子离子导航视图不会更改

时间:2015-03-29 14:19:59

标签: angularjs routes ionic-framework

我正在尝试在Ionic中执行身份验证页面。登录正在运行,当我按下登录时,视图将更改为离子选项卡。但是当我按下“没有帐户?” 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>

1 个答案:

答案 0 :(得分: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