简体   繁体   English

如何在Angular JS验证中添加自己的类名

[英]How to add own class name in angular js validation

I need one help.I want to add my defined class name in Angular.js validation.I am explaining my code below. 我需要一个帮助。我想在Angular.js验证中添加定义的类名。我在下面解释我的代码。

 <div ng-class="{ 'has-error': billdata.email.$touched && billdata.email.$invalid }">
<input type="email" name="email" id="procolgmail" class="form-control" placeholder="Add email id" ng-model="colgemail" ng-pattern="/^[_a-z0-9]+(\.[_a-z0-9]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/">
    </div>

Here has-error is the default class and it gives the light red color border.I need do it to dark red color. 这里has-error是默认的类,它给出了浅红色的边框,我需要将其设置为深红色。 can i add my class instead of its default class ?Please help. 我可以添加我的班级而不是其默认班级吗?请帮忙。

It is easy. 这很容易。 You need define your css class in your css file: for example: 您需要在css文件中定义css类:例如:

 .myError {
   border: 1px solid green;
}

And now : <div ng-class="{ 'myError': billdata.email.$touched && billdata.email.$invalid }"> 现在: <div ng-class="{ 'myError': billdata.email.$touched && billdata.email.$invalid }">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM