Browse Source

Update toaster-service.md

pull/23275/head
Fahri Gedik 1 year ago
parent
commit
ea56152eb6
  1. 35
      docs/en/framework/ui/angular/toaster-service.md

35
docs/en/framework/ui/angular/toaster-service.md

@ -8,12 +8,13 @@ You do not have to provide the `ToasterService` at module or component level, be
```js ```js
import { ToasterService } from '@abp/ng.theme.shared'; import { ToasterService } from '@abp/ng.theme.shared';
import { inject } from '@angular/core';
@Component({ @Component({
/* class metadata here */ /* class metadata here */
}) })
class DemoComponent { class DemoComponent {
constructor(private toaster: ToasterService) {} private toaster = inject(ToasterService);
} }
``` ```
@ -36,22 +37,23 @@ Options can be passed as the third parameter to `success`, `warn`, `error`, and
```js ```js
import { Toaster, ToasterService } from '@abp/ng.theme.shared'; import { Toaster, ToasterService } from '@abp/ng.theme.shared';
//... import { inject } from '@angular/core';
constructor(private toaster: ToasterService) {} // Sınıf içinde:
private toaster = inject(ToasterService);
//... //...
const options: Partial<Toaster.ToastOptions> = { const options: Partial<Toaster.ToastOptions> = {
life: 10000, life: 10000,
sticky: false, sticky: false,
closable: true, closable: true,
tapToDismiss: true, tapToDismiss: true,
messageLocalizationParams: ['Demo', '1'], messageLocalizationParams: ['Demo', '1'],
titleLocalizationParams: [], titleLocalizationParams: [],
iconClass: 'custom-icon-name'; iconClass: 'custom-icon-name'
}; };
this.toaster.error('AbpUi::EntityNotFoundErrorMessage', 'AbpUi::Error', options); this.toaster.error('AbpUi::EntityNotFoundErrorMessage', 'AbpUi::Error', options);
``` ```
- `life` option is the closing time in milliseconds. Default value is `5000`. - `life` option is the closing time in milliseconds. Default value is `5000`.
@ -93,15 +95,16 @@ If you want the ABP to utilize 3rd party libraries for the toasters instead of t
```js ```js
// your-custom-toaster.service.ts // your-custom-toaster.service.ts
import { Injectable } from '@angular/core'; import { Injectable, inject } from '@angular/core';
import { Config, LocalizationService } from '@abp/ng.core'; import { Config, LocalizationService } from '@abp/ng.core';
import { Toaster } from '@abp/ng.theme.shared'; import { Toaster } from '@abp/ng.theme.shared';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
@Injectable() @Injectable()
export class CustomToasterService implements Toaster.Service { export class CustomToasterService implements Toaster.Service {
constructor(private toastr: ToastrService, private localizationService: LocalizationService) {} private toastr = inject(ToastrService);
private localizationService = inject(LocalizationService)
error( error(
message: Config.LocalizationParam, message: Config.LocalizationParam,
title?: Config.LocalizationParam, title?: Config.LocalizationParam,

Loading…
Cancel
Save