我有两种形式的注册和登录,代码在单个控制器下编写,两个函数调用提交第一个表单正常工作,但注册总是在https://plnkr.co/edit/RS2LVc?p=preview中显示错误预览
var app = angular.module('abc', []);
app.controller('login', function ($scope) {
scope.LoginValidator = function ($event) {
if ($scope.LoginForm.$valid) {
console.log('Logged In');
} else {
console.log("invalid");
if ($scope.LoginForm.Email.$invalid) {
$scope.mailRequire = true;
}
if ($scope.LoginForm.password.$invalid) {
$scope.passRequire = true;
}
$event.preventDefault();
}
};
然后第二个函数从这里开始并显示错误
$scope.SignupValidator = function ($event) {
if ($scope.SignupForm.$valid) {
console.log("Valid");
} else {
alert('InValid Data');
if ($scope.SignupForm.Fullname.$invalid) {
$scope.namerequire = true;
}
if ($scope.SignupForm.email.$invalid) {
$scope.emailrequire = true;
}
if ($scope.SignupForm.rollno.$invalid) {
$scope.rollrequire = true;
}
if ($scope.SignupForm.password.$invalid) {
$scope.passwordrequire = true;
}
if ($scope.SignupForm.confirm.$invalid) {
$scope.confirmrequire = true;
}
$event.preventDefault();
}
};
});