Javascript 设置登录凭据并转到下一页并显示下一页
我的代码很难设置登录凭据,无法转到下一页并显示下一页 HTML代码 我使用ng模型在登录控制器上获取js文件上的数据Javascript 设置登录凭据并转到下一页并显示下一页,javascript,html,angularjs,ionic-framework,Javascript,Html,Angularjs,Ionic Framework,我的代码很难设置登录凭据,无法转到下一页并显示下一页 HTML代码 我使用ng模型在登录控制器上获取js文件上的数据 <form method="post" > <div id="form-wrapper" ng-controller="LoginCtrl"> <label class="item item-input item-floating-label"> <
<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>
主页控制器
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',
];
});
登录页面控制器
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页面上的登录按钮时,什么也没发生。如果有人能帮我解决这个问题,请指教
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!'
});
});
}
});
如果其他内容都正确,请从表单html中删除
method=“post”
,使其与以下内容类似:
<form novalidate ng-submit="login()">
// your input boxes
....
<button type="submit">Login</button>
</form>
//您的输入框
....
登录
在我想到其他事情之前,先发表一点小评论。。。您的templateUrl是Lndex.html。。。可能是index.html。。另外,在控制台上看到任何错误吗?是的,我已经删除了该错误,但它仍然不会出现在任何地方