|
import { Component, ViewChild, OnInit, ElementRef } from '@angular/core';
import { DialogComponent } from '@syncfusion/ej2-angular-popups';
import { EmitType } from '@syncfusion/ej2-base';
export class AppComponent implements OnInit {
@ViewChild('ejDialog') ejDialog: DialogComponent;
// Create element reference for dialog target element.
@ViewChild('container', { read: ElementRef }) container: ElementRef;
// The Dialog shows within the target element.
public targetElement: HTMLElement;
// To get all element of the dialog component after component get initialized.
ngOnInit() {
this.initilaizeTarget();
}
// Initialize the Dialog component's target element.
public initilaizeTarget: EmitType<object> = () => {
this.targetElement = document.getElementById('container');
}
// Hide the Dialog when click the footer button.
public hideDialog: EmitType<object> = () => {
this.ejDialog.hide();
}
// Enables the footer buttons
public buttons: Object = [
{
'click': this.hideDialog.bind(this),
// Accessing button component properties by buttonModel property
buttonModel:{
content: 'OK',
// Enables the primary button
isPrimary: true
}
},
{
'click': this.hideDialog.bind(this),
buttonModel: {
content: 'Cancel'
}
}
];
// Sample level code to handle the button click action
public onOpenDialog = function(event: any): void {
// Call the show method to open the Dialog
this.ejDialog.show();
};
} |