[Angular2 Form] Style Validation in Angular 2 Forms
Inputs using Angular 2’s ngModel automatically apply style classes of .ng-validand .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 Componentdecorator.
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 ...
随机推荐
- CRF模型
CRF的全称是Conditional Random Fields,由CMU教授John Lafferty 提出,原文标题:Conditional R andom Fields: Probabilist ...
- 【LeetCode】83 - Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and ret ...
- Python 学习笔记(六)正则扩展标记
1. (?:...) 不想保存括号里匹配项时使用 The (?:...) notation should be fairly popular; with it, you can groupparts ...
- javascript对象事件绑定方法
javascript对象事件绑定方法 今天在做对象事件绑定的过程中出现了一点异外情况,由于事件方法是由参数传过来的,需要将当前对象call过去,方便方法体里直接调用this 错误写法 obj.oncl ...
- BITED程序员语言学习心得之:C#语言基础
一.HelloWorld 我们先来看看最简单的C#代码——HelloWorld: using System; using System.Collections.Generic; using Syste ...
- Strom学习笔记一
---恢复内容开始--- Storm 是个实时的.分布式以及具备高容错的计算系统.同Hadoop一样Storm也可以处理大批量的数据,然而Storm在保证高可靠性的前提下还可以让处理进行的更加实时:也 ...
- EventSource (node.js 与 OC)
node.js服务器代码: var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, ...
- Uva 11183 - Teen Girl Squad (最小树形图)
Problem ITeen Girl Squad Input: Standard Input Output: Standard Output You are part of a group of n ...
- Ngix 移动端与Pc端 反向代理判断
如神马搜索和百度(http://www.baidu.com),当用桌面浏览器和移动浏览器访问的结果是不一样的.其中的手段可能有两种: 转载Ngix反向代理判断 服务端直接判断UA输出不同的界面,JAV ...
- Operation not applicable
ClientDataSet.DataSetProvider1 Operation not applicable ClientDataSet1->Open(); 解决办法 1.update new ...