Modal Dialog box within another component

I have tried the example here and it works.  What I want to achieve is to enable programmatic modal box popup on a button click within another component.  The example from syncfusion website launches the dialog box upon loading.  How do it do that?   Thank you.

http://ej2.syncfusion.com/15.4.17/angular/documentation/dialog/getting-started.html

5 Replies

GS Gobalakrishnan S Syncfusion Team December 2, 2017 09:23 AM UTC

Hi Albert, 
Thanks for using Syncfusion products. 
We have prepared the simple sample as per your requirement (“to enable programmatic modal box popup on a button click within another component”). Please find the sample on the below plunker. 
If still you face any difficulties or if we have misunderstood your requirement, kindly get back to us with more additional information to identify your exact requirement. or please revert back the provided sample based on your application along with the replication procedure. This would be more helpful for us to provide a better solution at the earliest. 
Regards, 
Gobalakrishnan S 



AK Albert K December 2, 2017 09:51 AM UTC

In your example the target  referes to the Html element id of  "dialog-container" which is the id of the "",  Is this the default way of doing this or can we anchor it to the "selector" of @Component of the current page.  

Also your example does not work on Microsoft Edge 41.16299.15, meaning that you cannot dismiss the dialog box by clicking on the overlay.

Edge Debug error
ERROR TypeError: Unable to get property 'remove' of undefined or null reference

  (overlayClick)="removeDialogComponent($event)" [target]='targetElement'  width='250px'>


NP Narayanasamy Panneer Selvam Syncfusion Team December 4, 2017 04:30 PM UTC

Hi Albert, 
Query1: In your example the target refers to the Html element id of "dialog-container" which is the id of the "",  Is this the default way of doing this or can we anchor it to the "selector" of @Component of the current page. 
 
In the previous sample, we have set the "dialog-container" id to the selector element ( <app-container>) of the given page and assigned as target to the Dialog component. 
Yes, you can also use selector element as target to the Dialog component which is given in @Component of the current page. 
 
Query2:  example does not work on Microsoft Edge 41.16299.15. 
Sorry for the inconvenience caused. 
Due to some restriction with traversing in edge browser, the issue has occurred. Please find the modified runnable sample in the below link  
Please let us know if you have further queries. 
 
Regards, 
Narayanasamy P. 



KR Kenana Reda November 28, 2018 11:40 AM UTC

Hi!
I need to open modal from another component, I had a look on the example here, but it doesn't seems achieve what I need, Could you explain with more details in simple way?




PO Prince Oliver Syncfusion Team November 30, 2018 06:08 PM UTC

Hi Kenana,  
 
Thank you for contacting Syncfusion support 
 
You can render the dialog within another component by using angular selectors. Also, you can pass the data by using angular service. It helps to pass the values between angular components. Please refer the below code block  
  
[app.service.ts]  
  
import { ComponentInjectable } from '@angular/core';  
  
@Injectable()  
  
// create the sepearate sevice for dialog  
export class ShareRouting {  
public dialogContentstring;  
  
constructor() {  
// setting the default value  
this.dialogContent = '';  
}  
  
setData(data) {  
this.dialogContent = data;  
}  
getData() {  
return this.dialogContent;  
}  
}  
  
  
  
Based on your requirement we have prepared the sample. Please find the sample at the following location:  
   
Regards,  
Prince  


Loader.
Up arrow icon