Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

angular readonly if value is not null

(a) add property at component.ts 

export class UserAddUpdateComponent implements OnInit {
    readOnly :boolean = this.data != null ? true:false;
(b) in component.html
   <input
     formControlName="userName"
     matTooltip="Enter User Name"
     matInput
     placeholder="User Name"
     required
     [readonly]="this.readOnly"
    />
 
PREVIOUS NEXT
Tagged: #angular #readonly #null
ADD COMMENT
Topic
Name
3+8 =