Skip to content

Commit 5aa71ee

Browse files
authored
Merge pull request Stabzs#173 from Stabzs/release/6.1.0
feat(toast.body bypass trusted html)
2 parents 3979e4e + 3345613 commit 5aa71ee

File tree

5 files changed

+67
-12
lines changed

5 files changed

+67
-12
lines changed

CHANGELOG.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
# 6.1.0 (2018-06-21)
2+
### FEATURES
3+
* **toaster-container.component:** Added bypassSecurityTrustHtml support for the body parameter
4+
for the `TrustedHtml` body output type. Thanks to @TGNC for making the change.
5+
6+
### DOCUMENTATION
7+
* **readme:** Documented ErrorHandler cases. Closes [#169](https://github.com/Stabzs/Angular2-Toaster/issues/169).
8+
19
# 6.0.0 (2018-05-19)
210
### FEATURES
3-
* **angular2-toaster:** Full release of 6.0.0 functionality. Pins the library to 6.0.0 versions of Angular and RxJS.
4-
Closes [#161](https://github.com/Stabzs/Angular2-Toaster/issues/161).
11+
* **angular2-toaster:** Full release of 6.0.0 functionality. Pins the library to 6.0.0 versions
12+
of Angular and RxJS. Closes [#161](https://github.com/Stabzs/Angular2-Toaster/issues/161).
513

614

715
# 5.1.0 (2018-05-19)
@@ -12,8 +20,8 @@ a toastId. Thanks to @sherlock1982 for his work on
1220

1321
### BUG FIXES
1422
* **toaster-container.component:** Mouseover functionality would incorrectly remove a toast when
15-
the toast's timeout was set to 0 and the container's configuration was set to a value other than
16-
0. Closes [#164](https://github.com/Stabzs/Angular2-Toaster/issues/164).
23+
the toast's timeout was set to 0 and the container's configuration was set to a value other than 0.
24+
Closes [#164](https://github.com/Stabzs/Angular2-Toaster/issues/164).
1725

1826

1927
# 5.0.1 (2018-03-16)

README.md

+28-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ largely based off of [AngularJS-Toaster](https://github.com/jirikavi/AngularJS-T
66
[![npm](https://img.shields.io/npm/v/angular2-toaster.svg?maxAge=3600?caching=true)](https://www.npmjs.com/package/angular2-toaster)
77
[![npm](https://img.shields.io/npm/dt/angular2-toaster.svg?caching=true)](https://www.npmjs.com/package/angular2-toaster)
88
[![Build Status](https://travis-ci.org/Stabzs/Angular2-Toaster.svg?branch=master)](https://travis-ci.org/Stabzs/Angular2-Toaster)
9-
[![Coverage Status](https://coveralls.io/repos/github/Stabzs/Angular2-Toaster/badge.svg?branch=master&b=6.0.0)](https://coveralls.io/github/Stabzs/Angular2-Toaster?branch=master)
9+
[![Coverage Status](https://coveralls.io/repos/github/Stabzs/Angular2-Toaster/badge.svg?branch=master&b=6.1.0)](https://coveralls.io/github/Stabzs/Angular2-Toaster?branch=master)
1010

1111

1212
Version ^5.0.0 requires either `.forRoot()` or `.forChild()` `ToasterModule` inclusion. Please
@@ -560,6 +560,32 @@ Run Karma test instance with coverage report:
560560
npm run test
561561
```
562562
563+
# Frequently Asked Questions and Issues
564+
## I get the `No Toaster Containers have been initialized to receive toasts.` error
565+
566+
You have not properly initialized a toaster container instance before trying to publish a toast.
567+
Make sure that you have rendered the `toaster-container` component and that you are importing
568+
the `ToasterModule` with `ToasterModule.forRoot()`.
569+
570+
## Toasts are not displayed when popped from an error handler
571+
The `handleError` function is executed outsize of an Angular zone. You need to
572+
explicitly tell Angular to run the pop call within the context of a zone.
573+
574+
```TypeScript
575+
export class AppErrorHandler implements ErrorHandler {
576+
constructor(
577+
private toasterService: ToasterService,
578+
private ngZone : NgZone) { }
579+
580+
handleError(error: any): void {
581+
this.ngZone.run(() => {
582+
this.toasterService.pop('error', "Error", error);
583+
});
584+
}
585+
}
586+
```
587+
(See this great [Stack Overflow Answer]( https://stackoverflow.com/questions/44975477/angular2-ng-toasty-errorhandler) for more details).
588+
563589
564590
## Author
565591
@@ -570,7 +596,7 @@ Rewritten from https://github.com/jirikavi/AngularJS-Toaster
570596
Inspired by http://codeseven.github.io/toastr/demo.html.
571597
572598
## Copyright
573-
Copyright © 2016-2017 Stabzs.
599+
Copyright © 2016-2018 Stabzs.
574600
575601
576602
## Licence

demo/angular-cli/src/app/routes/home/home/home.component.html

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<h1>
55
Welcome to {{ title }}!
66
<button (click)="popToast()">pop toast</button>
7+
<button (click)="toto()">pop toto toast</button>
78
</h1>
89
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
910
</div>
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
import { Component } from '@angular/core';
2-
import { ToasterService, IToasterConfig, ToasterConfig } from '@angular2-toaster/angular2-toaster';
1+
import { Component, AfterViewInit } from '@angular/core';
2+
import { ToasterService, IToasterConfig, ToasterConfig, Toast } from '@angular2-toaster/angular2-toaster';
33

44
@Component({
55
selector: 'app-root',
66
templateUrl: './home.component.html',
77
})
8-
export class HomeComponent {
8+
export class HomeComponent implements AfterViewInit {
99
title = 'home';
1010

1111
constructor(public toasterService: ToasterService) {}
1212

1313
homeConfig: IToasterConfig = new ToasterConfig({
14-
animation: 'fade', newestOnTop: false,
15-
positionClass: 'toast-bottom-center', toastContainerId: 4
14+
animation: 'fade',
15+
newestOnTop: false,
16+
positionClass: 'toast-bottom-center',
17+
toastContainerId: 4
1618
});
1719

1820
popToast() {
@@ -24,4 +26,22 @@ export class HomeComponent {
2426

2527
window.setTimeout(() => toast.title = 'Updated Home Title', 1000)
2628
}
29+
30+
ngAfterViewInit() {
31+
console.log('entering view init');
32+
const toast: Toast = {
33+
type: 'success',
34+
body: 'I am init toast'
35+
};
36+
this.toasterService.pop(toast);
37+
}
38+
39+
toto() {
40+
console.log('toto button clicked');
41+
const toast: Toast = {
42+
type: 'success',
43+
body: 'I am toto toast'
44+
};
45+
this.toasterService.pop(toast);
46+
}
2747
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular2-toaster",
3-
"version": "6.0.0",
3+
"version": "6.1.0",
44
"description": "An Angular Toaster Notification library based on AngularJS-Toaster",
55
"main": "bundles/angular2-toaster.umd.js",
66
"module": "angular2-toaster.js",

0 commit comments

Comments
 (0)