We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Dialog in service

Hi Team,


How I can use Dialog and Notification in service in entryComponents?
Example:
Regards

3 Replies

PO Prince Oliver Syncfusion Team July 10, 2019 12:08 AM

Hi Marko, 

Thank you for contacting us. 

You can use the Dialog component and Toast component as an Angular service component. The service is a stateless object that contains public functions and maintains the data throughout the life of an application. These functions can be invoked from any Angular component like Controllers, Directives, and more. Please find the below sample for Dialog Component.  


In above sample,   
            We have created Dialog component as a separate service using @Injectable(). 
            In this service, we have created common functions like showDialog, hideDialog etc.  
            We have shown/hidden the Dialog component with dynamically updated content using showDialog/hideDialog service method when the buttons are clicked. 

For Toast Component, please refer to the following KB documentation: https://www.syncfusion.com/kb/10340/how-to-use-toast-as-an-angular-service 

Kindly check the above solution and let us know if you need any further assistance on this. 

Regards, 
Prince 



JR Jaco Roux December 7, 2020 06:45 AM

Is it possible to render other components or ng-templates as part of the content property of the dialog service?

Currently I use 


<div #modal>
  <ng-container *ngIf="showModal">
    <div *ngTemplateOutlet='content'></div>
  </ng-container>
</div>

<ng-template #content>
  <h1>Hello world</h1>
</ng-template>


And in the component code:

@ViewChild('modal', { statictrue }) modalElementRef;


Then pass in nativeElement of modal as the content
this.modal.nativeElement





IS Indrajith Srinivasan Syncfusion Team December 8, 2020 05:25 AM

Hi Jaco,

Greetings from Syncfusion support,
 
 
We have validated your reported query. Yes, you can render the dialog using the ng-templates. We have also prepared a sample that tries to meet your requirements. 
 
 
Can you please check the above sample and let us know if it meets your requirements ? 
 
Regards, 
Indrajith 


Loader.
Live Chat Icon For mobile
Up arrow icon