简体   繁体   中英

How to validate md-select in angular material 2?

everyone.

I am developing app with angular and I am using Angular material for UI.

I know about angular validation

https://angular.io/docs/ts/latest/cookbook/form-validation.html

How can I validate md-select ?

You can validate md-select the same way it's shown in the documentation. The main idea is to create a reference #someName and the use that reference to do the validation. There are six controls that Angular provides: touched, untouched, dirty, pristine, valid and invalid.

I created a Plunker demo for you with the dirty validation for md-select .

You can read more about validation in the "Track control state and validity with ngModel" section, here: https://angular.io/docs/ts/latest/guide/forms.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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