Javascript 在角度形式下,无法显示跨度
我无法看到使用angularjs单击提交按钮时出现的错误消息。 任何线索都将被感激 提前感谢:)Javascript 在角度形式下,无法显示跨度,javascript,html,css,angularjs,Javascript,Html,Css,Angularjs,我无法看到使用angularjs单击提交按钮时出现的错误消息。 任何线索都将被感激 提前感谢:) 请提供有效的出生日期 提交 .controller('ExampleController',函数($scope、$location、$scope、$stateparms){ $scope.singleSelect=''; $scope.goToPage=函数(){ console.log(“selectservice”); $location.path(“/selectservice”); } $
请提供有效的出生日期
提交
.controller('ExampleController',函数($scope、$location、$scope、$stateparms){
$scope.singleSelect='';
$scope.goToPage=函数(){
console.log(“selectservice”);
$location.path(“/selectservice”);
}
$scope.submituser=函数($scope){
if($scope.form.$valid){}else{
$scope.submitted=true;
}
}
})
请检查表单名称
您使用了两个不同的名称
name=“form”在表单标签中,用作输入字段中的signUpForm.dob
检查您的ng型号以
<form id="formbody" ng-submit="submituser(form)" name="signUpForm" novalidate>
<input type="text" ng-class="{ errorinput: submitted && signUpForm.dob.$invalid }" name="dob" ng-model="form.dob" placeholder="Date of Birth" required />
<span class="e" ng-if="submitted && signUpForm.dob.$invalid">Please provide a valid date of birth</span>
<div style="padding-left: 275px;">
<button type="submit">Submit</button>
</div>
</div>
</form>
.controller('ExampleController',function($scope,$location,$scope, $stateParams){
$scope.singleSelect='';
$scope.goToPage=function(){
console.log("selectservice");
$location.path("/selectservice");
}
$scope.submitted =false;
$scope.submituser = function(form){
// console.log(form);
if (form.$valid) {
your logic
} else {
$scope.submitted = true;
}
}
})
请提供有效的出生日期
提交
.controller('ExampleController',函数($scope、$location、$scope、$stateparms){
$scope.singleSelect='';
$scope.goToPage=function(){
console.log(“selectservice”);
$location.path(“/selectservice”);
}
$scope.submitted=false;
$scope.submituser=函数(表单){
//控制台日志(表格);
如果(表格$valid){
你的逻辑
}否则{
$scope.submitted=true;
}
}
})
请检查表单名称
您使用了两个不同的名称
name=“form”在表单标签中,用作输入字段中的signUpForm.dob
检查您的ng型号以
<form id="formbody" ng-submit="submituser(form)" name="signUpForm" novalidate>
<input type="text" ng-class="{ errorinput: submitted && signUpForm.dob.$invalid }" name="dob" ng-model="form.dob" placeholder="Date of Birth" required />
<span class="e" ng-if="submitted && signUpForm.dob.$invalid">Please provide a valid date of birth</span>
<div style="padding-left: 275px;">
<button type="submit">Submit</button>
</div>
</div>
</form>
.controller('ExampleController',function($scope,$location,$scope, $stateParams){
$scope.singleSelect='';
$scope.goToPage=function(){
console.log("selectservice");
$location.path("/selectservice");
}
$scope.submitted =false;
$scope.submituser = function(form){
// console.log(form);
if (form.$valid) {
your logic
} else {
$scope.submitted = true;
}
}
})
请提供有效的出生日期
提交
.controller('ExampleController',函数($scope、$location、$scope、$stateparms){
$scope.singleSelect='';
$scope.goToPage=function(){
console.log(“selectservice”);
$location.path(“/selectservice”);
}
$scope.submitted=false;
$scope.submituser=函数(表单){
//控制台日志(表格);
如果(表格$valid){
你的逻辑
}否则{
$scope.submitted=true;
}
}
})
将ng显示的span
更改为
<span class="e" ng-show="submitted && form.dob.$invalid">Please provide a valid date of birth</span>
请提供有效的出生日期
将ng显示的span
更改为
<span class="e" ng-show="submitted && form.dob.$invalid">Please provide a valid date of birth</span>
请提供有效的出生日期
您必须提供表单名称,但即使在此之后,您也不能在控制器中引用表单,除非您通过提交函数参数传递表单名称。此外,控制器中没有signupForm()
函数
要走的路是:
<form id="formbody" name="myForm" ng-submit="signupForm(myForm)" novalidate>
<!-- inputs etc -->
</form>
另一方面,如果您不想弄乱控制器,您可以始终使用FormController
方法$submitted
。这看起来像:
<span class="e" ng-show="myForm.$submitted && myForm.dob.$invalid">Please provide a valid date of birth</span>
请提供有效的出生日期
您必须提供表单名称,但即使在此之后,您也不能在控制器中引用表单,除非您通过提交函数参数传递表单名称。此外,控制器中没有signupForm()
函数
要走的路是:
<form id="formbody" name="myForm" ng-submit="signupForm(myForm)" novalidate>
<!-- inputs etc -->
</form>
另一方面,如果您不想弄乱控制器,您可以始终使用FormController
方法$submitted
。这看起来像:
<span class="e" ng-show="myForm.$submitted && myForm.dob.$invalid">Please provide a valid date of birth</span>
请提供有效的出生日期
试试这样的方法
你的出生日期
请提供有效的出生日期
提交
试试这样的方法
你的出生日期
请提供有效的出生日期
提交
我已经纠正了它,现在错误就要来了。“TypeError:无法在ChildScope读取未定义的属性'signUpForm'。$scope.submituser”$scope.submituser函数名位于控制器中,您正在调用模板ng submit=“signUpForm()”中的某些signUpForm()是的,以前我已经编辑过,但在更正后,此错误即将出现。请尝试上面的方法是的,它正在工作,但我希望在单击“提交”按钮后显示span。我已更正,现在错误即将出现。“TypeError:无法在ChildScope读取未定义的属性'signUpForm'。$scope.submituser”$scope.submituser函数名位于控制器中,您正在调用模板ng submit=“signUpForm()”中的某些signUpForm()是的,之前我写过,但更正后,此错误即将出现。请尝试上面的方法是的,它正在工作,但我希望在单击“提交”按钮后显示span。不需要将表单作为参数发送。不需要将表单作为参数发送。