我的表单验证在点击提交按钮时不起作用。我已经正确添加控制器HTMl.Any铅会appreciated.Thanks提前:)Angular JS表单验证不起作用
<form id="formbody" ng-submit="submit(user)" name="form" novalidate="">
<div class="formtext" >
<div class="has-header">
<ion-label class="labelstyle" > Select Service </ion-label>
<input ng-click="goToPage()" name="selectsrve" type="text" class="formtext1 inputimg" ng-model="user.firstname" placeholder=" Select from list" required="">
<!-- <img src="img/icon-arrow-gray.png"></img> -->
</input>
<span ng-show="user.firstname.$dirty && users.firstname.$error.required">Please select the Service</span>
</div>
<div style="padding-left: 275px;">
<button type="submit">Submit</button>
<!-- <div type="button" id="btn" style="color: red;" >Submit</div> -->
</div>
</div>
</form>
.controller('ExampleController',function($scope,$location,$scope, $stateParams){
$scope.singleSelect='';
$scope.goToPage=function(){
console.log("selectservice");
$location.path("/selectservice");
}
$scope.submit = function(){
// Set the 'submitted' flag to true
alert("In the submit button");
$scope.submit=function(user){
alert("user"+user.firstName);
};
}
})
那是因为我必须按一下在I/P,并从那里我有选择的服务导航到另一个页面。如果它是空的,则应显示错误。 –