angularjs – 带有自定义templateUrl的$mdDialog.confirm()

前端之家收集整理的这篇文章主要介绍了angularjs – 带有自定义templateUrl的$mdDialog.confirm()前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在我的应用程序中使用$mdDialog,但是想将它用作“确认”对话框而不是正常对话框.这意味着,在用户单击确认对话框中的两个按钮之一之前,代码流不应继续.我注意到可以使用$mdDialog.confirm(),但我不知道如何将它与自定义templateUrl和相应的控制器一起用作对话框的内容.

以下是我所写的,就对话框而言可以正常工作,但是在打开对话框后代码流不会停止.它应该停止,直到用户点击“确定”或“取消”.

$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");
   }
基本上它会是这样的:
var confirm = $mdDialog.confirm({
      controller: 'incomingCallDialogController',parent: angular.element(document.body)
   })
   $mdDialog.show(confirm).then(function() {
      console.log("here");
   }

这是一个codepen.

原文链接:https://www.f2er.com/angularjs/142199.html

猜你在找的Angularjs相关文章