Pass variable in *ngIf

Asked

Viewed 510 times

2

I have a variable in my input.component.ts calling for validacaoExterna, that receives a string from whoever is going to use it..

@Input() validacaoExterna: string;

In my input.component.html I have a *ngIf that uses this variable

*ngIf="input.errors."{{validacaoExterna}}" && (input.dirty || input.touched)"

But this way is not working. I wonder how I can use this variable within this *ngIf, where it takes the error value in the input + this variable input.erro.validacaoExterna

  • 1

    tries thus *ngIf="input.errors[validatorExterna] && (input.Dirty || input.Touched)"

  • 1

    The right and you save this expression in a variable and do *ngIf="variable" has as you show more code to try to understand the context

  • 1

    It worked perfectly Eduardo, can mark as a response I give the OK here! Thank you very much.

1 answer

1


 *ngIf="input.errors[validacaoExterna] && (input.dirty || input.touched)"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.