if you use angular2 -toaster (npm install angular2 -toaster)
in html
<button class='btn btn-bar btn-warn' (click)='testToaster()'>testToaster</button>
in the .js component
import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; import { ToasterModule, ToasterService, BodyOutputType } from "angular2-toaster"; @NgModule({ imports: [ BrowserAnimationsModule, ToasterModule], }) export class Democlass extends BaseComponent implements OnInit { constructor(..., private toasterService: ToasterService) { . . .} public testToaster() { this.toasterService.pop("info", "Args Title info", "Args Body <p/> sdf") .bodyOutputType = BodyOutputType.TrustedHtml; }
you can also use other toast properties like
let toast = this.toasterService.pop("info", "demo Title info", "demo Body <p/> sdf"); toast.bodyOutputType = BodyOutputType.TrustedHtml; // these will be used toast.title = "Actual tite"; toast.body = "new html body <i>italic</i><hr/>notes"; // toast.clickHandler = ... // toast.type = "error"; // toast.timeout = 20; // ...
source share