Javascript Angular JS表单验证不起作用

Javascript Angular JS表单验证不起作用,javascript,html,angularjs,ionic-framework,Javascript,Html,Angularjs,Ionic Framework,单击“提交”按钮时,我的表单验证无效。我已经在HTMl中正确添加了控制器。任何潜在客户都将不胜感激。提前感谢:) 选择服务 请选择服务 提交 .controller('ExampleController',函数($scope、$location、$scope、$stateparms){ $scope.singleSelect=''; $scope.goToPage=function(){ console.log(“selectservice”); $location.path(“/select

单击“提交”按钮时,我的表单验证无效。我已经在HTMl中正确添加了控制器。任何潜在客户都将不胜感激。提前感谢:)


选择服务
请选择服务
提交
.controller('ExampleController',函数($scope、$location、$scope、$stateparms){
$scope.singleSelect='';
$scope.goToPage=function(){
console.log(“selectservice”);
$location.path(“/selectservice”);
}
$scope.submit=函数(){
//将“已提交”标志设置为true
警报(“在提交按钮中”);
$scope.submit=函数(用户){
警报(“用户”+用户名);
};
}
})

您的
$scope.submit
函数应该是这样的。删除另一个
$scope.submit
函数。为什么在输入中有一个
ng点击
?当你点击你的输入时,它会重定向

$scope.submit = function(user){

     alert("user"+user.firstName);
}

我对您的代码做了一些更改

在span中,而不是
user.firstname.$dirty&&users.firstname.$error.required
您应该使用表单名称和输入字段名称
form.$submitted&&form.selectsrve.$invalid&&form.selectsrve.$error.required

您还可以在
ng submit
中使用条件来提交表单,前提是该表单有效
ng submit=“form.$valid&&submit(form)”

在控制器中,使用scope变量获取用户

$scope.submit=function(){
        alert("user "+$scope.user.firstname);
    };

请看一下这个

,因为我必须通过单击该i/p导航到另一个页面,然后从那里选择服务。如果为空,则应显示错误。
$scope.submit=function(){
        alert("user "+$scope.user.firstname);
    };