AngularJS-需要父指令的手动编译指令

AngularJS-需要父指令的手动编译指令,angularjs,angularjs-directive,Angularjs,Angularjs Directive,我正在尝试手动编译指令,这需要一些其他指令控制器 F.E 在其他一些指令链接函数中,我正在执行: var newElement = $compile('<my-directive>')(scope); element.replaceWith(newElement); //element is of course children of "otherDirective". var newElement=$compile(“”)(范围); 元素。替换为(新元素); //元素当然是“ot

我正在尝试手动编译指令,这需要一些其他指令控制器

F.E

在其他一些指令链接函数中,我正在执行:

var newElement = $compile('<my-directive>')(scope);
element.replaceWith(newElement);
//element is of course children of "otherDirective".
var newElement=$compile(“”)(范围);
元素。替换为(新元素);
//元素当然是“otherDirective”的子元素。
这给了我一个错误: 错误:[$compile:ctreq]找不到指令“myDirective”所需的控制器“otherDirective”


如何修复此问题?

由于
myDirective
需要
otherDirective
,因此我看到的唯一方法是包装编译,即
$compile(“”)(scope)
或修改您的设计。@NikosParaskevopoulos:您逆转我的设计是什么意思?我想要的是在ng repeat中有条件地应用我的指令。这是“修改”,而不是“反转”。您可能需要提供有关特定用例的更多信息。顺便问一下,您在这方面运气好吗?
var newElement = $compile('<my-directive>')(scope);
element.replaceWith(newElement);
//element is of course children of "otherDirective".