Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getToasterConfig(): ToasterConfig {
this.toasterConfigured = true;
return new ToasterConfig({
bodyOutputType: BodyOutputType.TrustedHtml,
positionClass: "toast-bottom-right"
});
}
title: msg.title,
};
if (typeof (msg.text) === 'string') {
toast.body = msg.text;
} else if (msg.text.length === 1) {
toast.body = msg.text[0];
} else {
let message = '';
msg.text.forEach((t: string) =>
message += ('<p>' + this.sanitizer.sanitize(SecurityContext.HTML, t) + '</p>'));
toast.body = message;
toast.bodyOutputType = BodyOutputType.TrustedHtml;
}
if (msg.options != null) {
if (msg.options.trustedHtml === true) {
toast.bodyOutputType = BodyOutputType.TrustedHtml;
}
if (msg.options.timeout != null && msg.options.timeout > 0) {
toast.timeout = msg.options.timeout;
}
}
this.toasterService.popAsync(toast);
}
}
this.config = new ToasterConfig({
positionClass: 'toast-top-right',
timeout: 10000,
newestOnTop: true,
tapToDismiss: true,
preventDuplicates: false,
animation: 'slideDown',
limit: 1,
});
const toast: Toast = {
type: type,
title: title,
body: body,
timeout: 10000,
showCloseButton: true,
bodyOutputType: BodyOutputType.TrustedHtml,
};
this.toaster.popAsync(toast);
}
title: msg.title,
};
if (typeof (msg.text) === 'string') {
toast.body = msg.text;
} else if (msg.text.length === 1) {
toast.body = msg.text[0];
} else {
let message = '';
msg.text.forEach((t: string) =>
message += ('<p>' + this.sanitizer.sanitize(SecurityContext.HTML, t) + '</p>'));
toast.body = message;
toast.bodyOutputType = BodyOutputType.TrustedHtml;
}
if (msg.options != null) {
if (msg.options.trustedHtml === true) {
toast.bodyOutputType = BodyOutputType.TrustedHtml;
}
if (msg.options.timeout != null && msg.options.timeout > 0) {
toast.timeout = msg.options.timeout;
}
}
this.toasterService.popAsync(toast);
}
this.config = new ToasterConfig({
positionClass: 'toast-top-right',
timeout: 10000,
newestOnTop: true,
tapToDismiss: true,
preventDuplicates: false,
animation: 'slideDown',
limit: 1,
});
const toast: Toast = {
type: type,
title: title,
body: body,
timeout: 10000,
showCloseButton: true,
bodyOutputType: BodyOutputType.TrustedHtml,
};
this.toaster.popAsync(toast);
}
}
this.config = new ToasterConfig({
positionClass: 'toast-top-right',
timeout: 10000,
newestOnTop: true,
tapToDismiss: true,
preventDuplicates: false,
animation: 'slideDown',
limit: 1,
});
const toast: Toast = {
type: type,
title: title,
body: body,
timeout: 10000,
showCloseButton: true,
bodyOutputType: BodyOutputType.TrustedHtml,
};
this.toaster.popAsync(toast);
}
this.config = new ToasterConfig({
positionClass: 'toast-top-right',
timeout: 10000,
newestOnTop: true,
tapToDismiss: true,
preventDuplicates: false,
animation: 'slideDown',
limit: 1,
});
const toast: Toast = {
type: type,
title: title,
body: body,
timeout: 10000,
showCloseButton: true,
bodyOutputType: BodyOutputType.TrustedHtml,
};
this.toaster.popAsync(toast);
}
getToasterConfig(): ToasterConfig {
this.toasterConfigured = true;
return new ToasterConfig({
bodyOutputType: BodyOutputType.TrustedHtml,
positionClass: "toast-bottom-right"
});
}
import { Injectable } from '@angular/core';
import { BodyOutputType, Toast, ToasterConfig, ToasterService } from 'angular2-toaster';
@Injectable()
export class NotificationService {
private _toastSuccess: Toast = {
type : 'success',
bodyOutputType: BodyOutputType.TrustedHtml,
};
private _toastError: Toast = {
type : 'error',
bodyOutputType: BodyOutputType.TrustedHtml,
};
constructor(private _ts: ToasterService) {
}
public success(title: string = '', body: string = ''): void {
this._toastSuccess.title = title;
this._toastSuccess.body = body;
this._ts.pop(this._toastSuccess);
}
this.config = new ToasterConfig({
positionClass: 'toast-top-right',
timeout: 10000,
newestOnTop: true,
tapToDismiss: true,
preventDuplicates: false,
animation: 'slideDown',
limit: 1,
});
const toast: Toast = {
type: type,
title: title,
body: body,
timeout: 10000,
showCloseButton: true,
bodyOutputType: BodyOutputType.TrustedHtml,
};
this.toaster.popAsync(toast);
}