question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MdInput doesn't set required asterisk when the validator is set in reactive forms

See original GitHub issue

Bug, feature request, or proposal:

The placeholder from the MdInput does not show the asterisk (*) when we use Validators.required in the FormControl.

What is the expected behavior?

The asterisk should be shown as it is when setting the requiredattribute.

What are the steps to reproduce?

http://plnkr.co/edit/XqkOmF502Q8RFj8qcUwp?p=preview or take a look at the input-container-demo

What is the use-case or motivation for changing an existing behavior?

To be not dependet on the template to visually indicate that the input is required.

Which versions of Angular, Material, OS, browsers are affected?

all (to my knowlege it never worked)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:115
  • Comments:59 (10 by maintainers)

github_iconTop GitHub Comments

49reactions
eltonplimacommented, Jun 22, 2017

I’m using this solution:

<input formControlName="name" [required]="formGroup.get('name').errors !== null && formGroup.get('name').errors.required">

39reactions
Antoniosssscommented, May 26, 2020

Any ETA ??

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add 'required field' asterisk to angular reactive form ...
My solution by generate new Directive: ng generate directive directive/mark-asterisk. This is full code of directive:
Read more >
Is This Possible With Reactive Forms? : r/angular - Reddit
Is there an easy way to do this with reactive forms? ... MdInput doesn't set required asterisk when the validator is set in...
Read more >
Material Input Auto Required Asterisk - StackBlitz
Form field with error messages. ... import {FormsModule, ReactiveFormsModule}. from '@angular/forms'; ... app/mat-input-required.directive';.
Read more >
3 ways to implement conditional validation of Angular reactive ...
After we're all set, let's try to implement conditional validation. If checkbox value is true , we will set the required validator to...
Read more >
Angular Reactive Forms: trigger validation on submit
Displaying the required field asterisk (*); Validating all fields on ... In this form we have name , email and a set of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found