Click from HTML Ionic 2 Controller
2 answers
You can do this using DomSanitizationService
. Service import
import {DomSanitizationService} from '@angular/platform-browser';
Now, in the class constructor, do this
constructor(sanitizer: DomSanitizationService) {
this.text = '<a (click)="myAlert()">Show allert</a>' ;
this.text = sanitizer.bypassSecurityTrustHtml(this.text);
}
Use this template in your template
<div [innerHTML]="text"></div> // here the DOM will be appended
Have a look at this answer to keep track of release and import versions updates
+2
source to share