ElementRef.find() 不是函数 angular 2

ElementRef.find() not a function angular 2

我正在尝试将我的 angular 1 指令代码转换为 angular 2。但是它会抛出一个错误,指出 ElementRef.find() 不是一个函数。有没有其他方法可以达到同样的目的。在元素中查找元素。

Angular 1

link: function ($scope, $elem, attrs) {
            var elem = $elem[0] table = $elem,
                thead = table.find('thead'),
                tbody = table.find('tbody'),
       }

Angular 2

 constructor(el: ElementRef, renderer: Renderer) {
    this.elem = el.nativeElement;
    this.table = el,
    this.thead = this.table.find('thead');
    this.tbody = this.table.find('tbody');
    this.tableWidth = this.table[0].getBoundingClientRect().width;
}

构造函数(私有 el:ElementRef,私有渲染器:Renderer){}

 //ngAfterContentInit() { // for directive or projected content
 ngAfterViewInit() { // for searching a components template
    this.elem = el.nativeElement;
    this.table = el,
    this.thead = this.table.querySelector('thead');
    this.tbody = this.table.querySelector('tbody');
    this.tableWidth = this.table[0].getBoundingClientRect().width;
 }

findjQuery。 Angular2中没有jQuery

另见