How to set input field attribute 'readonly' from Angular component -
i want set 'readonly' property of quantity field during keypress on assetid field.
<!-- asset id field--> <div class="form-group"> <label for="asset id">asset id:</label> <input autocomplete="off" type="text" class="form-control" id="assetid" name="assetid" formcontrolname="assetid" (keypress)="setassetid()"> </div> <!-- quantity field--> <div class="form-group"> <label for="quantity">quantity:</label> <input autocomplete="off" type="text" class="form-control" id="quantity" name="quantity" formcontrolname="quantity"> </div>
here angular function:
public setassetid(){ console.log('key changed'); this.form.controls['quantity'].patchvalue(1); this.form.controls['quantity'].set('readonly'); // want }
please me regarding this...
you can set property input event following:
typescript:
isok: boolean; public setassetid(){ .... isok = true; }
html
<input autocomplete="off" [readonly]="isok" type="text" class="form-control" id="quantity" name="quantity" formcontrolname="quantity">
Comments
Post a Comment