Angular 2 - 如何访问指令并调用其中的成员函数

Angular 2 - how to access directive and call a member function in it

我有这样的指令 -

@Directive({
    selector:   'someDirective'
})
export class  SomeDirective{         
    constructor() {}    
    render = function() {}
}

然后我导入指令

import {SomeDirective} from '../../someDirective';
@Page({
    templateUrl: '....tem.html',
    directives: [SomeDirective]
})
export class SomeComponent {
      constructor(){}
      ngAfterViewInit(){//want to call the render function in the directive
}

在ngAfterViewInit中,我想在指令中调用render函数。 如何做到这一点?

这是老办法,

@Directive({
    selector:   'someDirective'
})
export class  SomeDirective{         
    constructor() {}    
    render() {
       console.log('hi from directive');
    }
}

import {Component,ViewChild} from 'angular2/core';
import {SomeDirective} from '../../someDirective';
@Component({
    templateUrl: '....tem.html',
    directives: [SomeDirective]
})
export class SomeComponent {
      @ViewChild(SomeDirective) vc:SomeDirective;
      constructor(){}
      ngAfterViewInit(){
          this.vc.render();
      }
}

对于较新版本的 Angular2,请遵循此处给出的答案