Angular2单独的#template变量,用于自定义组件实例

时间:2018-07-10 13:58:18

标签: angular angular2-template angular-components angular2-components

我有一个自定义的角度分量:

@Component({
   selector: 'my-sel',
   template: `<div #myRef></div>`,
   styleUrls: ['...']
})
export class MyComponent {
    @ViewChild('myRef') public myRef: ElementRef;

    // other stuff goes here...
}

现在,当我在另一个组件模板中两次使用<my-sel></my-sel>时,我想分别引用myRef变量。

我没有找到解决方法。无处。 如何做到这一点?

0 个答案:

没有答案