AngularJS dindn';我不能在firefox中工作
我为一个web应用程序写了一个登录名。在chrome中,登录可以正常工作,但在firefox中不能AngularJS dindn';我不能在firefox中工作,angularjs,google-chrome,firefox,Angularjs,Google Chrome,Firefox,我为一个web应用程序写了一个登录名。在chrome中,登录可以正常工作,但在firefox中不能 <form ng-submit="$ctrl.login()"> <div class="cClearFloat"> <input type="text" name="Benutzername" placeholder="Benutzername" ng-model="$ctrl.userName"> </div>
<form ng-submit="$ctrl.login()">
<div class="cClearFloat">
<input type="text" name="Benutzername" placeholder="Benutzername" ng-model="$ctrl.userName">
</div>
<div class="cClearFloat">
<input type="password" name="Passwort" placeholder="Passwort" ng-model="$ctrl.password">
</div>
<div class="cClearFloat">
<div class="cButtonLogin" class="button">
<button class="cLinkLogin" type="submit">Anmelden</button>
</div>
</div>
</form>
登录:
login(userName, password) {
this.$http.post("http://localhost:20670/login", { UserName: userName, Password: password }).then((response) => {
this.userInfo = this.hateoasService.fromData(response.data);
this.$http.defaults.headers.common.LoginToken = this.userInfo.LoginToken;
this.isLoggedIn = true;
}, (response) => {
swal({
title: response.data.error,
type: 'error'
})
});
}
当我在firefox中测试它时,它会重新加载页面。有人知道为什么它不起作用吗?是否可能是因为angularjs不可用,并且他从ng submit获取默认值而导致重新加载
在我的控制台中,我犯了这个错误
在
表单上使用ng submit
,并将按钮类型更改为submit
在你看来:
<div ng-app="myApp" ng-controller="myCtrl">
<form ng-submit="login()">
<input type="text" name="Benutzername" placeholder="Benutzername" ng-model="model.userName">
<input type="password" name="Passwort" placeholder="Passwort" ng-model="model.password">
<button class="cLinkLogin" type="submit">Anmelden</button>
</form>
</div>
请参见我过去常使用查看控制台错误错误错误不在表单中,而是在某些对象调用中。请检查控制台错误的堆栈跟踪。堆栈跟踪用于angular.min.js文件,然后使用非缩小的angular进行调试。这些痕迹将更具描述性
<div ng-app="myApp" ng-controller="myCtrl">
<form ng-submit="login()">
<input type="text" name="Benutzername" placeholder="Benutzername" ng-model="model.userName">
<input type="password" name="Passwort" placeholder="Passwort" ng-model="model.password">
<button class="cLinkLogin" type="submit">Anmelden</button>
</form>
</div>
var app = angular.module("myApp", []);
app.controller("myCtrl", myCtrl);
function myCtrl($scope) {
$scope.model = {};
$scope.login = function() {
alert("username: " + $scope.model.userName + ", password: " + $scope.model.password);
}
}