From 1e638481e755e517d1195bd1fd0f7c276b3f30c3 Mon Sep 17 00:00:00 2001 From: ddincheva Date: Mon, 29 Jun 2020 13:32:34 +0300 Subject: [PATCH] feat(IgxToast): allow to pass a string param on show method #7156 --- .../src/lib/toast/toast.component.html | 2 +- .../src/lib/toast/toast.component.ts | 30 +++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/projects/igniteui-angular/src/lib/toast/toast.component.html b/projects/igniteui-angular/src/lib/toast/toast.component.html index 881efa9b509..b22a0c2376f 100644 --- a/projects/igniteui-angular/src/lib/toast/toast.component.html +++ b/projects/igniteui-angular/src/lib/toast/toast.component.html @@ -1,3 +1,3 @@ -{{ message }} +{{ toastMessage }} diff --git a/projects/igniteui-angular/src/lib/toast/toast.component.ts b/projects/igniteui-angular/src/lib/toast/toast.component.ts index 935c0e8d727..a6f843eb5ad 100644 --- a/projects/igniteui-angular/src/lib/toast/toast.component.ts +++ b/projects/igniteui-angular/src/lib/toast/toast.component.ts @@ -1,5 +1,6 @@ import { animate, state, style, transition, trigger } from '@angular/animations'; import { CommonModule } from '@angular/common'; +import { DeprecateProperty } from '../core/deprecateDecorators'; import { Component, ElementRef, @@ -205,10 +206,26 @@ export class IgxToastComponent implements IToggleView, OnInit, OnDestroy { public isVisibleChange = new EventEmitter(); /** - * @hidden + * @deprecated Place your message in the toast content instead. + * Sets/gets the message that will be shown by the toast. + * ```html + * + * ``` + * ```typescript + * let toastMessage = this.toast.message; + * ``` + * @memberof IgxToastComponent */ + @DeprecateProperty(`'message' property is deprecated. + You can use place the message in the toast content or pass it as parameter to the show method instead.`) @Input() - public message = ''; + public set message(value: string) { + this.toastMessage = value; + } + + public get message() { + return this.toastMessage; + } /** * Sets/gets the position of the toast. @@ -235,6 +252,12 @@ export class IgxToastComponent implements IToggleView, OnInit, OnDestroy { return this.elementRef.nativeElement; } + /** + * @hidden + * @internal + */ + toastMessage = ''; + /** * @hidden */ @@ -252,8 +275,9 @@ export class IgxToastComponent implements IToggleView, OnInit, OnDestroy { * ``` * @memberof IgxToastComponent */ - public show(): void { + public show(message?: string): void { clearInterval(this.timeoutId); + if (message !== undefined) { this.toastMessage = message; } this.onShowing.emit(this); this.isVisible = true; this.animationState = 'visible';