Trying to create a Angular directive for password show/hide functionality. the show/hide works, however when trying to use a material design (mat) button it does not show the mat button it shows a default html button. In the directive I have
toggle(span: HTMLElement) {
this._shown = !this._shown;
if (this._shown) {
this.el.nativeElement.setAttribute('type', 'text');
span.innerHTML = '<button mat-raised-button color="primary">Hide</button>';
} else {
this.el.nativeElement.setAttribute('type', 'password');
span.innerHTML = '<button mat-raised-button color="primary">Show</button>';
}
}
in the app.component.html I do have some buttons working as a test so I do know mat is working.
<div>
<button mat-raised-button>basic</button>
<button mat-raised-button color="primary">primary</button>
</div>
<div>
<label>Enter Password</label>
<input type="password" appPassword>
</div>
My question is using a directive which uses the innerHTML how can I get material design buttons to work?
thanks