Ionic ion-nav-view 在更改 URL 后不会改变
Iconic ion-nav-view dont change after change the URL
我正在尝试在 Ionic 中创建身份验证页面。登录正常,当我按登录时,视图更改为离子选项卡。但是当我按下 "Don't have an account?" 时,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>
这看起来不对...
.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
我正在尝试在 Ionic 中创建身份验证页面。登录正常,当我按登录时,视图更改为离子选项卡。但是当我按下 "Don't have an account?" 时,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>
这看起来不对...
.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