Skip to content

Commit 23776b1

Browse files
committed
Update README.md
1 parent f4a94e3 commit 23776b1

File tree

1 file changed

+20
-49
lines changed

1 file changed

+20
-49
lines changed

README.md

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,33 @@ DEMO: https://ngx-toastr.vercel.app
1818
## Features
1919

2020
- Toast Component Injection without being passed `ViewContainerRef`
21-
- No use of `*ngFor`. Fewer dirty checks and higher performance.
21+
- No use of `@for`. Fewer dirty checks and higher performance
22+
- No use of `@angular/animations`
2223
- AoT compilation and lazy loading compatible
2324
- Component inheritance for custom toasts
2425
- SystemJS/UMD rollup bundle
25-
- Animations using Angular's
26-
[Web Animations API](https://angular.io/docs/ts/latest/guide/animations.html)
2726
- Output toasts to an optional target directive
2827

2928
## Dependencies
3029

3130
Latest version available for each version of Angular
3231

33-
| ngx-toastr | Angular |
34-
| ---------- | ----------- |
35-
| 13.2.1 | 10.x 11.x |
36-
| 14.3.0 | 12.x 13.x |
37-
| 15.2.2 | 14.x. |
38-
| 16.2.0 | 15.x |
39-
| 17.0.2 | 16.x |
40-
| current | >= 17.x |
32+
| ngx-toastr | Angular |
33+
| --------------- | --------------- |
34+
| 13.2.1 | 10.x 11.x |
35+
| 14.3.0 | 12.x 13.x |
36+
| 15.2.2 | 14.x. |
37+
| 16.2.0 | 15.x |
38+
| 17.0.2 | 16.x |
39+
| 18.x 19x | >= 17.x < 23.x |
40+
| current | >= 20.x |
4141

4242
## Install
4343

4444
```bash
4545
npm install ngx-toastr --save
4646
```
4747

48-
`@angular/animations` package is a required dependency for the default toast
49-
50-
```bash
51-
npm install @angular/animations --save
52-
```
53-
54-
Don't want to use `@angular/animations`? See
55-
[Setup Without Animations](#setup-without-animations).
56-
5748
## Setup
5849

5950
**step 1:** add css
@@ -91,20 +82,15 @@ Don't want to use `@angular/animations`? See
9182
]
9283
```
9384

94-
**step 2:** add `ToastrModule` to app `NgModule`, or `provideToastr` to providers, make sure you have `BrowserAnimationsModule` (or `provideAnimations`) as well.
85+
**step 2:** add `ToastrModule` to app `NgModule`, or `provideToastr` to providers.
9586

9687
- Module based
9788

9889
```typescript
99-
import { CommonModule } from '@angular/common';
100-
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
101-
10290
import { ToastrModule } from 'ngx-toastr';
10391

10492
@NgModule({
10593
imports: [
106-
CommonModule,
107-
BrowserAnimationsModule, // required animations module
10894
ToastrModule.forRoot(), // ToastrModule added
10995
],
11096
bootstrap: [App],
@@ -117,13 +103,10 @@ class MainModule {}
117103

118104
```typescript
119105
import { AppComponent } from './src/app.component';
120-
import { provideAnimations } from '@angular/platform-browser/animations';
121-
122106
import { provideToastr } from 'ngx-toastr';
123107

124108
bootstrapApplication(AppComponent, {
125109
providers: [
126-
provideAnimations(), // required animations providers
127110
provideToastr(), // Toastr providers
128111
]
129112
});
@@ -133,10 +116,11 @@ bootstrapApplication(AppComponent, {
133116

134117
```typescript
135118
import { ToastrService } from 'ngx-toastr';
119+
import { inject } from '@angular/core';
136120

137121
@Component({...})
138122
export class YourComponent {
139-
constructor(private toastr: ToastrService) {}
123+
toastr = inject(ToastrService);
140124

141125
showSuccess() {
142126
this.toastr.success('Hello world!', 'Toastr fun!');
@@ -231,8 +215,6 @@ imports: [
231215

232216
```typescript
233217
import { AppComponent } from './src/app.component';
234-
import { provideAnimations } from '@angular/platform-browser/animations';
235-
236218
import { provideToastr } from 'ngx-toastr';
237219

238220
bootstrapApplication(AppComponent, {
@@ -281,20 +263,13 @@ an `aria-live="polite"` attribute, so that any time a toast is injected into
281263
the container it is announced by screen readers.
282264

283265
```typescript
284-
import { BrowserModule } from '@angular/platform-browser';
285266
import { NgModule } from '@angular/core';
286-
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
287-
288267
import { ToastrModule, ToastContainerDirective } from 'ngx-toastr';
289-
290268
import { AppComponent } from './app.component';
291269

292270
@NgModule({
293271
declarations: [AppComponent],
294272
imports: [
295-
BrowserModule,
296-
BrowserAnimationsModule,
297-
298273
ToastrModule.forRoot({ positionClass: 'inline' }),
299274
ToastContainerDirective,
300275
],
@@ -307,8 +282,7 @@ export class AppModule {}
307282
Add a div with `toastContainer` directive on it.
308283

309284
```typescript
310-
import { Component, OnInit, ViewChild } from '@angular/core';
311-
285+
import { Component, OnInit, viewChild, inject } from '@angular/core';
312286
import { ToastContainerDirective, ToastrService } from 'ngx-toastr';
313287

314288
@Component({
@@ -319,10 +293,9 @@ import { ToastContainerDirective, ToastrService } from 'ngx-toastr';
319293
`,
320294
})
321295
export class AppComponent implements OnInit {
322-
@ViewChild(ToastContainerDirective, { static: true })
323-
toastContainer: ToastContainerDirective;
296+
toastContainer = viewChild(ToastContainerDirective, { static: true });
297+
toastrService = inject(ToastrService);
324298

325-
constructor(private toastrService: ToastrService) {}
326299
ngOnInit() {
327300
this.toastrService.overlayContainer = this.toastContainer;
328301
}
@@ -366,8 +339,8 @@ map: {
366339

367340
## Setup Without Animations
368341

369-
If you do not want to include `@angular/animations` in your project you can
370-
override the default toast component in the global config to use
342+
If you do not want animations you can override the default
343+
toast component in the global config to use
371344
`ToastNoAnimation` instead of the default one.
372345

373346
In your main module (ex: `app.module.ts`)
@@ -378,16 +351,14 @@ import { ToastrModule, ToastNoAnimation, ToastNoAnimationModule } from 'ngx-toas
378351
@NgModule({
379352
imports: [
380353
// ...
381-
382-
// BrowserAnimationsModule no longer required
383354
ToastNoAnimationModule.forRoot(),
384355
],
385356
// ...
386357
})
387358
class AppModule {}
388359
```
389360

390-
That's it! Animations are no longer required.
361+
That's it! No animations.
391362

392363
## Using A Custom Toast
393364

0 commit comments

Comments
 (0)