[Angular2 Form] Reactive Form, show error message for one field

Source: Internet
Author: User

<form [formgroup]="Reactiveform"Novalidate autocomplete="off"> <divclass="Form-field"> <label>Title:</label> <input formcontrolname="title"> <divclass="Field-error-message"*ngif="reactiveForm.controls.title.errors?. Required">Title isRequired</div></form>

In this tutorial we is going to learn how do we mark form fields in error and display error messages to the user of Angular 2 model driven forms. We'll see that the approach are similar than what do we do while using template driven forms, but in this case we don t hav E template exports available.

We are going to see how the FormControl API exposes a list of controls each with a separate status and its own list of err ORS, and how that can is used to display messages to the user.

[Angular2 Form] Reactive Form, show error message for one field

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.