Search results

Open a dialog on popup item click

This section explains about how to open a dialog on SplitButton popup item click. This can be achieved by handling dialog open in select event of the SplitButton.

In the following example, Dialog will open while selecting Update... item:

Source
Preview
app.component.ts
app.module.ts
main.ts
import { Component, ViewChild } from '@angular/core';
import { ItemModel, MenuEventArgs  } from '@syncfusion/ej2-angular-splitbuttons';
import { DialogComponent } from '@syncfusion/ej2-angular-popups';

@Component({
    selector: 'app-root',
    template: `<!-- To render Dialog. -->
               <ejs-dialog #dialog [buttons]='alertDlgButtons' [visible]='false' content='Are you sure want to update?' width='250px' header='Software Update'>
               </ejs-dialog>
               <!-- To Render splitbutton. -->
               <ejs-splitbutton content="Help" [items]='items' (select)='select($event)'></ejs-splitbutton>`
})

export class AppComponent {
    @ViewChild('dialog')
    public alertDialog: DialogComponent;

    public items: ItemModel[] = [
    {
        text: 'Help'
    },
    {
        text: 'About'
    },
    {
        text: 'Update...'
    }];

    public alertDlgButtons: Object[] = [{
        buttonModel: {
            isPrimary: true,
            content: 'Ok',
        },
        click: function () {
            this.hide();
        }
    },
    {
        buttonModel: {
            isPrimary: true,
            content: 'Cancel',
        },
        click: function () {
            this.hide();
        }
    }];

    public select (args: MenuEventArgs) {
        if (args.item.text === 'Update...') {
            this.alertDialog.show();
        }
    }
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { SplitButtonModule } from '@syncfusion/ej2-angular-splitbuttons';
import { DialogModule } from '@syncfusion/ej2-angular-popups';

/**
 * Module
 */
@NgModule({
    imports: [
        BrowserModule,
        SplitButtonModule,
        DialogModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);