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

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -