[Angular2 Form] Style Validation in Angular 2 Forms
Inputs using Angular 2’s ngModel
automatically apply style classes of .ng-valid
and .ng-invalid
each time the input’s validity changes. These classes allow you easily add your own styles simply by declaring the styles
in your Component
decorator.
import { Component, OnInit } from '@angular/core'; @Component({
selector: 'app-message',
templateUrl: './message.component.html',
styleUrls: ['./message.component.css']
})
export class MessageComponent implements OnInit { message = "Hello"; constructor() { } ngOnInit() {
} onSubmit(formValue){
console.log("formValue", JSON.stringify(formValue, null, ))
}
}
input.ng-dirty.ng-valid.ng-touched{
border-bottom: green 2px solid;
}
input.ng-invalid.ng-dirty.ng-touched{
border: 2px solid red;
}
[Angular2 Form] Style Validation in Angular 2 Forms的更多相关文章
- [Angular2 Form] Group Inputs in Angular 2 Forms with ngModelGroup
The ngModelGroup directive allows you to group together related inputs so that you structure the obj ...
- [Angular2 Form] Display Validation and Error Messaging in Angular 2
Angular 2’s ngModel provides error objects for each of the built-in input validators. You can access ...
- [Angular2 Router] Style the Active Angular 2 Navigation Element with routerLinkActive
You can easily show the user which route they are on using Angular 2’s routerLinkActive. Whenever a ...
- [Angular2 Form] Angular 2 Template Driven Form Custom Validator
In this tutorial we are going to learn how we can also implement custom form field validation in Ang ...
- [Angular2 Form] Create Radio Buttons for Angular 2 Forms
Using Radio Buttons in Angular 2 requires a basic understanding of forms as well as how their labels ...
- [Angular2 Form] Use RxJS Streams with Angular 2 Forms
Angular 2 forms provide RxJS streams for you to work with the data and validity as it flows out of t ...
- [Angular2 Form] Model Driven Form Custom Validator
In this tutorial we are going to learn how simple it is to create custom form field driven validator ...
- Adding Validation to our Album Forms 添加类属性的一些验证特性
Adding Validation to our Album Forms We’ll use the following Data Annotation attributes: Required – ...
- shit element ui & form password validation
shit element ui & form password validation shit docs https://github.com/yiminghe/async-validator ...
随机推荐
- C语言实现strlen
strlen: #ifndef STRLEN_H #define STRLEN_H #include <stdio.h> // 参考微软的写法 int cat_strlen(const c ...
- 33条C#、.Net经典面试题目及答案
33条C#..Net经典面试题目及答案[zt] 本文集中了多条常见的C#..Net经典面试题目例如".NET中类和结构的区别"."ASP.NET页面之间传递值的几种方式? ...
- mybatis系列-16-spring和mybatis整合
16.1 整合思路 需要spring通过单例方式管理SqlSessionFactory. spring和mybatis整合生成代理对象,使用SqlSessionFactory创建SqlSess ...
- (转载)OC学习篇之---Foundation框架中的NSDirctionary类以及NSMutableDirctionary类
昨天学习了Foundation框架中NSArray类和NSMutableArray类,今天来看一下Foundation框架中的NSDirctionary类,NSMutableDirctionary类, ...
- BITED-Windows8应用开发学习札记之二:Win8应用常用视图设计
感觉自我表述能力有欠缺,技术也不够硬,所以之后的Windows8应用开发学习札记的文章就偏向于一些我认为较难的地方和重点了多有抱歉. 上节课是入门,这节课就已经开始进行视图设计了. Windows应用 ...
- 【脚本语言对比】BASH,PERL以及PYTHON
据说: BASH能调用linux的应用程序,这是其最大的优点,也是其最大的缺点. PERL那复杂的语法确实看得让人想吐. python很优美,但是据说对正则的支持不够,没有perl强大. 总结一下学习 ...
- 终于把你必须知道的.NET看完了
终于把你必须知道的.NET看完了,第二步就是把精通ASP.NET MVC3框架这本书搞定,练习MVC3的使用,并把EF,LINQ也练习一下,期间要做一个项目“多用户微信公众平台”项目,最近微信公众平台 ...
- Linux Shell脚本教程
v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VM ...
- hadoop 异常及处理总结-01(小马哥-原创)
试验环境: 本地:MyEclipse 集群:Vmware 11+ 6台 Centos 6.5 Hadoop版本: 2.4.0(配置为自动HA) 试验背景: 在正常测试MapReduce(下简称MR)程 ...
- c++声明与定义
c++声明与定义 声明是将一个名称引入程序.定义提供了一个实体在程序中的唯一描述.声明和定义有时是同时存在的. 如 int a; extern int b=1; 只有当extern中不存在初始化才是 ...