我有一个自定义指令,我已经创建了一个模板加载到模态窗口。模态窗口本身就是一个模板,并且能够运行我的自定义指令而没有问题。加载到模式中的模板包含使用angular-selectize创建选择列表的另一个指令。这是我的指令:嵌套指令不编译
var dynamicTemplate = function($templateRequest, $compile) {
return {
restrict: "E",
link: function(scope, element, attrs) {
var modalOptions = JSON.parse(attrs.modalOptions);
$templateRequest(modalOptions.Url).then(function(html) {
$elem = $compile(html)(scope);
element.append($elem);
});
}
}
}
HTML正在正确加载,但selectize指令未初始化。
我也厌倦了这样的then
方法中:
element.html(html)
$compile(element.contents())(scope);
这给了我同样的结果。
我遇到的问题是,我的HTML的编译后收到此消息:
TypeError: element.selectize is not a function
这里是the plunk我一起工作。
我不明白倒票。 – superczan