I want to change the text of the input placeholder dynamically. The console.log already gives the updated string but the interface doesn’t update so there stays the old placeholder. How can I get the Interface to recognize the change?
JavaScript
x
4
1
document.getElementById(this.implicKey).setAttribute('placeholder', options[i].implication);
2
3
console.log(document.getElementById(this.implicKey).getAttribute('placeholder'));
4
Advertisement
Answer
you can change your input placeholder dynamically like this
JavaScript
1
5
1
<md-input-container class="demo-full-width">
2
<input mdInput [(ngModel)]="firstname" placeholder="{{somePlaceholder}}" name="firstname" required>
3
<md-error>This field is required</md-error>
4
</md-input-container>
5
component.ts
JavaScript
1
2
1
somePlaceholder : string = "new value";
2
now you can change somePlaceholder value any where in the class.