如何在指令中要求组件?您可以在另一个指令中要求一个指令的控制器,也可以在另一个组件中要求一个组件。但是如何在指令中要求组件控制器?
指示:
export class Directive {
require = "^^parentComponent";
restrict = "A";
link = (scope, element, attrs, parentComponent) => {
}
app.directive("someDirective", /* Init code omitted for brewity */);
}
html:
<parent-component>
<div some-directive> </div>
</parent-component>
我收到以下错误:
Error: [$compile:ctreq] Controller 'parentComponent', required by directive 'someDirective', can't be found!
http://errors.angularjs.org/1.5.0/$compile/ctreq?p0=InvoiceCre