【发布时间】:2017-05-05 04:26:25
【问题描述】:
我有登录页面。当用户名和密码正确时,我想从登录页面重定向到 HomePage.html 页面。
Login.html
<ion-view view-title="Login" name="login-view">
<ion-content class="padding">
<div class="list list-inset">
<label class="item item-input">
<input type="text" placeholder="Username" ng-model="data.username">
</label>
<label class="item item-input">
<input type="password" placeholder="Password" ng-model="data.password">
</label>
</div>
<button class="button button-block button-calm" ng-click="login()">Login</button>
</ion-content>
</ion-view>
HomePage.html
<label id="test">test</label>
controller.js
.controller('LoginCtrl', function ($scope, LoginService, $ionicPopup, $state) {
$scope.data = {};
$scope.login = function () {
LoginService.loginUser($scope.data.username, $scope.data.password).success(function (data) {
$state.go('/HomePage'); // This is not working for me
}).error(function (data) {
var alertPopup = $ionicPopup.alert({
title: 'Login failed!',
template: 'Please check your credentials!'
});
});
}
})
问题:
当我尝试下面的代码时
$state.go('/HomePage');
这对我不起作用。
我得到以下异常
Error: Could not resolve '/HomePage' from state 'login'
如何从登录页面访问 homepage.html 页面。
我们将不胜感激。
谢谢。
【问题讨论】:
-
在这里发布 app.js
-
我也忘记添加新路径到 app.js 感谢回答
标签: javascript html angularjs ionic-framework