How to enable or disable any button in angular 2 based on mandatory and optional field -
i want save button enabled when placeholder value 'optional'.when value 'mandatory' save button should disabled , enabled if enter value field.
my template-
<md-input name="" [placeholder]="isoptional()"></md-input> <input type="button" disabled="placeholder==='mandatory'" value="save">
in typescript file-
isoptional(){ if (cond1|| cond2){ return 'mandatory'; } else if (cond3||cond4){ return 'optional'; }
i trying above in template not getting proper output.any idea going wrong?
try following:
<md-input name="" #input [placeholder]="isoptional()"></md-input> <input type="button" disabled="input.placeholder === 'mandatory'" value="save">
Comments
Post a Comment