我有一個自定義指令,我已經創建了一個模板加載到模態窗口。模態窗口本身就是一個模板,並且能夠運行我的自定義指令而沒有問題。加載到模式中的模板包含使用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