0
我有我的代碼中設置的登錄憑據,以進入下一個頁面,顯示下一頁組登錄憑證,並移動到下一個頁面,顯示下一頁
HTML代碼 我困難「M使用NG-模型獲得關於JS文件數據登錄控制器
<form method="post" >
<div id="form-wrapper" ng-controller="LoginCtrl">
<label class="item item-input item-floating-label">
<h2 class="light">
Enter Username</h2> <input type="text" id="username" ng-model="username" placeholder="Username">
</label>
<label class="item item-input item-floating-label">
<h2 class="light">
Enter Password</h2> <input type="Password" id="password" ng-model="password" placeholder="*********">
</label>
<button class="button button-block button-positive" ng-click="login()">
login
</button>
</div>
</form>
JS CODE上 STATES
angular.module('starter', ['ionic'])
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url: '/home',
templateUrl: 'page2.html',
controller: 'HomeCtrl'
})
.state('login', {
url: '/login',
templateUrl: 'lndex.html',
controller: 'LoginCtrl'
})
$urlRouterProvider.otherwise('/login');
});
主頁CONTROLLER
angular.module('starter', ['ionic'])
.controller('HomeCtrl', function() {
this.photos = [
'img/weq.gif',
'img/a.gif',
'img/b.gif',
'img/c.gif',
'img/d.gif',
'img/qw.gif',
];
});
登錄頁面控制器
這是因爲它控制着我的離子模塊的主文件,問題是當我登錄按鈕點擊html頁面,然後沒事就happen.kindly如果有人可以幫助我解決這個問題?
angular.module('starter', ['ionic'])
.controller('LoginCtrl', function($scope, LoginService, $ionicPopup, $state) {
$scope.data = {
};
$scope.login = function() {
console.log("LOGIN user: " + $scope.username + " - PW: " + $scope.password);
LoginService.loginUser($scope.username, $scope.password).success(function(data) {
console.log("Login Successful");
$state.go('home');
}).error(function(data) {
var alertPopup = $ionicPopup.alert({
title: 'Login failed!',
template: 'Please check your credentials!'
});
});
}
});
做,但沒有再次發生:/ –
未成年評論之前,我想其他的某事.. 。你的templateUrl是Lndex.html ...可能是index.html ..另外,請查看控制檯上的任何錯誤? –
是的,我已經刪除了這個錯誤,但它仍然沒有去任何地方 –