Skip to content

Commit

Permalink
docs: update readme to include standalone provider function (#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
eneajaho authored May 4, 2023
1 parent 94dba28 commit c8074d6
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ Don't want to use `@angular/animations`? See
]
```

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

- Module based

```typescript
import { CommonModule } from '@angular/common';
Expand All @@ -114,6 +116,22 @@ import { ToastrModule } from 'ngx-toastr';
class MainModule {}
```

- Standalone

```typescript
import { AppComponent } from './src/app.component';
import { provideAnimations } from '@angular/platform-browser/animations';

import { provideToastr } from 'ngx-toastr';

bootstrapApplication(AppComponent, {
providers: [
provideAnimations(), // required animations providers
provideToastr(), // Toastr providers
]
});
```

## Use

```typescript
Expand Down Expand Up @@ -197,7 +215,9 @@ iconClasses = {

#### Setting Global Options

Pass values to `ToastrModule.forRoot()`
Pass values to `ToastrModule.forRoot()` or `provideToastr()` to set global options.

- Module based

```typescript
// root app NgModule
Expand All @@ -210,6 +230,26 @@ imports: [
],
```

- Standalone

```typescript
import { AppComponent } from './src/app.component';
import { provideAnimations } from '@angular/platform-browser/animations';

import { provideToastr } from 'ngx-toastr';

bootstrapApplication(AppComponent, {
providers: [
provideToastr({
timeOut: 10000,
positionClass: 'toast-bottom-right',
preventDuplicates: true,
}),
]
});
```


### Toastr Service methods return:

```typescript
Expand Down

0 comments on commit c8074d6

Please sign in to comment.