我有一个自定义指令,它添加了一些 html。
myAppModule.directive('myDirective', function() {
var linker = function(scope, element) {
return element.html("<b>directive loaded</b>");
};
return {
restrict: "E",
rep1ace: true,
link: linker,
scope: false
};
});
该指令在动态加载的 html 中加载和使用,该 html 包含在ng-include
.
<script type="text/javascript" src="dynamicscript.js"></script>
<my-directive>...</my-directive>
但它不起作用。-functionlinker
永远不会被调用。如果我将dynamicscript.js
脚本加载从包含的 html 移动到index.html
.