1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > [Angular2 Form] Style Validation in Angular 2 Forms

[Angular2 Form] Style Validation in Angular 2 Forms

时间:2021-11-24 12:32:48

相关推荐

[Angular2 Form] Style Validation in Angular 2 Forms

Inputs using Angular 2’sngModelautomatically apply style classes of.ng-validand.ng-invalideach time the input’s validity changes. These classes allow you easily add your own styles simply by declaring thestylesin yourComponentdecorator.

import { Component, OnInit } from '@angular/core';@Component({selector: 'app-message',templateUrl: './ponent.html',styleUrls: ['./ponent.css']})export class MessageComponent implements OnInit {message = "Hello";constructor() { }ngOnInit() {}onSubmit(formValue){console.log("formValue", JSON.stringify(formValue, null, 2))}}

input.ng-dirty.ng-valid.ng-touched{border-bottom: green 2px solid;}input.ng-invalid.ng-dirty.ng-touched{border: 2px solid red;}

Github

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。