[英]how to show red border in input field on button In angular js
Could you please tell how to show red border in the input field on a button in angularJs . 您能否告诉我如何在angularJs的按钮上的输入字段中显示红色边框。 Currently, the red border is displayed when the application load. 当前,在加载应用程序时显示红色边框。 Actually, I added ng-required validation on my form .but I want this only work after button click here is my code http://plnkr.co/edit/zL0cueTJN6xqxC4LzhOd?p=preview 实际上,我在表单上添加了ng所需的验证。但是,我希望此操作仅在按钮单击后才能起作用。这里是我的代码http://plnkr.co/edit/zL0cueTJN6xqxC4LzhOd?p=preview
<div class="form-group" ng-class="{'has-error': myform[key].$invalid}">
<input type="text" name="{{key}}" class="form-control" ng-model="value.value" ng-required="value.required">
</div>
Declare a variable $scope.isSubmitClicked=false;
声明一个变量$scope.isSubmitClicked=false;
in scope and make it true
in submit()
在范围上,并使其true
在submit()
$scope.isSubmitClicked = false;
$scope.submit = function ($event) {
$scope.isSubmitClicked = true;
};
Then 然后
<input type="text" name="{{key}}" class="form-control" ng-model="value.value" ng-required="value.required && isSubmitClicked">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.