Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$mdDialog.confirm() with custom templateUrl

I'm using $mdDialog in my application, but would like to use it as a "confirm" dialog instead of normal one. This means, the code flow should not proceed until user clicks on one of the two buttons in confirm dialog. I noticed that $mdDialog.confirm() can be used, but I'm not sure how to use it with custom templateUrl and a corresponding controller as the dialog's content.

Following is what I have written which works fine as far as dialog is concerned, but the code flow doesn't stop after the dialog is opened. It should stop until Ok or Cancel is clicked by the user.

$mdDialog.show({
      controller: 'incomingCallDialogController',
      templateUrl: 'app/components/others/incomingCallDialog/incomingCallDialog.tpl.html',
      locals: {message: message},
      parent: angular.element(document.body)
   }).then(function (answer) {
      console.log("here");
   }
like image 823
Developer Avatar asked Dec 21 '15 18:12

Developer


1 Answers

Basically it would be something like:

var confirm = $mdDialog.confirm({
      controller: 'incomingCallDialogController',
      templateUrl: 'app/components/others/incomingCallDialog/incomingCallDialog.tpl.html',
      locals: {message: message},
      parent: angular.element(document.body)
   })
   $mdDialog.show(confirm).then(function() {
      console.log("here");
   }

Here's a codepen.

like image 83
Daniel Avatar answered Nov 15 '22 06:11

Daniel