我使用了角度JS自定义指令编译函数,因为我无法获取已编译的HTML元素。我到了 -
<div id="test_{{value}}" modulename="test_{{value}}"></div>
如何在Post链接方法中获取已编译的html元素? 像这样,
<div id="test_1" modulename="test_1"></div>
编译函数代码如下,
module.directive("custom", ['$compile', function ($compile) {
return {
restrict: 'CEA',
transclude:true,
compile: function(el) {
if (settings.require && settings.require.length) {
return function(scope, el) {
$compile(el)(scope);
}
}
return {
pre: function(scope, element, attrs, ctrls) {
},
post: function(scope, element, attrs, ctrls) {
//here need to get compiled html element
}
}
}
};
}
提前致谢