0

如何在指令中要求组件?您可以在另一个指令中要求一个指令的控制器,也可以在另一个组件中要求一个组件。但是如何在指令中要求组件控制器?

指示:

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
4

1 回答 1

-1
require: '^parentComponent' 

作品

http://plnkr.co/edit/Rm53sWSJfnl7IVFzTjm2?p=preview

于 2016-07-21T09:55:18.910 回答