Skip to content

Commit 27d5558

Browse files
committed
feat(IgxToast): allow to pass a string param on show method #7156
1 parent fe3a767 commit 27d5558

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<ng-content></ng-content>
2-
<span>{{ message }}</span>
2+
<span>{{ toastMessage }}</span>
33

projects/igniteui-angular/src/lib/toast/toast.component.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { animate, state, style, transition, trigger } from '@angular/animations';
22
import { CommonModule } from '@angular/common';
3+
import { DeprecateProperty } from '../core/deprecateDecorators';
34
import {
45
Component,
56
ElementRef,
@@ -205,10 +206,26 @@ export class IgxToastComponent implements IToggleView, OnInit, OnDestroy {
205206
public isVisibleChange = new EventEmitter<boolean>();
206207

207208
/**
208-
* @hidden
209+
* @deprecated Place your message in the toast content instead.
210+
* Sets/gets the message that will be shown by the toast.
211+
* ```html
212+
* <igx-toast [message] = "Notification"></igx-toast>
213+
* ```
214+
* ```typescript
215+
* let toastMessage = this.toast.message;
216+
* ```
217+
* @memberof IgxToastComponent
209218
*/
219+
@DeprecateProperty(`'message' property is deprecated.
220+
You can use place the message in the toast content or pass it as parameter to the show method instead.`)
210221
@Input()
211-
public message = '';
222+
public set message(value: string) {
223+
this.toastMessage = value;
224+
}
225+
226+
public get message() {
227+
return this.toastMessage;
228+
}
212229

213230
/**
214231
* Sets/gets the position of the toast.
@@ -235,6 +252,12 @@ export class IgxToastComponent implements IToggleView, OnInit, OnDestroy {
235252
return this.elementRef.nativeElement;
236253
}
237254

255+
/**
256+
* @hidden
257+
* @internal
258+
*/
259+
toastMessage = '';
260+
238261
/**
239262
* @hidden
240263
*/
@@ -252,8 +275,9 @@ export class IgxToastComponent implements IToggleView, OnInit, OnDestroy {
252275
* ```
253276
* @memberof IgxToastComponent
254277
*/
255-
public show(): void {
278+
public show(message?: string): void {
256279
clearInterval(this.timeoutId);
280+
if (message !== undefined) { this.toastMessage = message; }
257281
this.onShowing.emit(this);
258282
this.isVisible = true;
259283
this.animationState = 'visible';

0 commit comments

Comments
 (0)