user9855223
user9855223

Reputation:

Angular 6 - *ngIf condition on input is something add attr readonly

I am trying to add a condition to an input where is a variable = view then I add the readonly attr to the input.

This is what I'm trying:

<input *ngIf="mode == 'view' readonly">

This is not working at the moment.

What I'm I doing wrong here?

Upvotes: 1

Views: 7270

Answers (1)

Yamini Chhabra
Yamini Chhabra

Reputation: 1149

Try

<input [readonly]="mode == 'view'">

It will add attribute readonly only when mode is equal to view

Upvotes: 10

Related Questions