角料组件在吴-甜警报-2 [英] Angular Material Components in Ng-Sweet-Alert-2
本文介绍了角料组件在吴-甜警报-2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试把一个HTML code,包括NG-甜警告对话框角材料输入组件(包括在我的项目):
I try to put an HTML code including Angular material input component (which is included in my project) in ng-sweet-alert dialog:
var strVar="";
strVar += "<div> <md-input-container style=\"padding-left:0px;\" flex=\"\">
<label>Titel<\/label> <input ng-model=\"WBQuery.Titel\">
<\/md-input-container> <\/div>";
swal({
title: 'HTML example',
html: strVar });
}
但什么是显示仅仅是HTML的标准输入字段。是否有任何(黑客)的方式在该对话框使用角度物质成分?
But what is shown is just the standard input field of HTML. Is there any (hacking) way to use angular material components in that dialog?
推荐答案
我还没有尝试过,但你可以试试这个。你调用 SwaI位
功能后,请尝试以下操作:
I've not tried it but you can try this. After you have invoked the swal
function, try the following:
(假设你正在做它在一个指令或控制器)
(Assuming you are doing it in a directive or a controller)
var element = angular.element(document.querySelector(".sweet-alert"));
$compile(element.contents())($scope);
如果不工作,尽量把上面的code在 $超时
服务:
If that doesn't work, try to put the above code in a $timeout
service:
$timeout(function() {
var element = angular.element(document.querySelector(".sweet-alert"));
$compile(element.contents())($scope);
}, 2000);
这篇关于角料组件在吴-甜警报-2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文