How to Close dialog box after 3 sec

I go through the sample code in tutorial but its works for me when I created app using aurelia cli but when I create same app using webpack that not work.

This is the code i taken from tutorial

import {EditPerson} from './edit-person';
  import {DialogService} from 'aurelia-dialog';
  export class Welcome {
    static inject = [DialogService];
    constructor(dialogService) {
      this.dialogService = dialogService;
    }
    person = { firstName: 'Wade', middleName: 'Owen', lastName: 'Watts' };
    submit(){
      this.dialogService.open({viewModel: EditPerson, model: this.person}).then(openDialogResult => {
        // Note you get here when the dialog is opened, and you are able to close dialog
        setTimeout(() => {
          openDialogResult.controller.cancel('canceled outside after 3 sec')
        }, 3000);

        // Promise for the result is stored in openDialogResult.closeResult property
        return openDialogResult.closeResult;
      }).then((response) => {
        if (!response.wasCancelled) {
          console.log('good');
        } else {
          console.log('bad');
        }
        console.log(response);
      });
    }
  }

My problem is close dialog box after 3 sec.

It depends which version of Aurelia-dialog you’re using, but unless you’re using a very old one, you should use whenClosed instead of then here. Otherwise you’ll have this part of the executed right after the dialog has been created whereas you’ll most probably want to have it executed when the dialog is closed.

Currently aurelia-dialog has issue with webpack, you cannot use EditPerson dialog directly.

Do

import {PLATFORM} from 'aurelia-pal';
//...
this.dialogService.open({viewModel: PLATFORM.moduleName('./edit-person'), model: this.person})

when I cording its gives this openDialogResult.controller.cancel there are no method in openDialogResult like controller.cancel that is error I got in when I work with webpack this code work properly aurelia CLI