我有一个组件,其模板看起来像这样:
<div [my-custom-directive]>Some content here</div>
Run Code Online (Sandbox Code Playgroud)
我需要访问此处使用的MyCustomDirective类实例.当我想要访问子组件时,我使用ng.core.ViewChild查询.是否有相同的功能来访问子指令?
我有这样的指示 -
@Directive({
selector: 'someDirective'
})
export class SomeDirective{
constructor() {}
render = function() {}
}
Run Code Online (Sandbox Code Playgroud)
然后我导入指令
import {SomeDirective} from '../../someDirective';
@Page({
templateUrl: '....tem.html',
directives: [SomeDirective]
})
export class SomeComponent {
constructor(){}
ngAfterViewInit(){//want to call the render function in the directive
}
Run Code Online (Sandbox Code Playgroud)
在ngAfterViewInit中,我想在指令中调用render函数.这该怎么做 ?