(a) add property at component.ts export class UserAddUpdateComponent implements OnInit { readOnly :boolean = this.data != null ? true:false; (b) in component.html <input [disabled]="this.readOnly" />