https://plnkr.co/edit/KrAV2oJWjSDMiqIyqtBi?p=preview
获得了一个创建,编译和注入组件的组件。 我有两个组件,我正在创建foo-bar和foopica-bar。 我已经创建了一个指令ContentEditableDirective,但不知何故看不到该指令。
在加载时,它应调用该指令并将背景颜色黄色添加到本机元素样式。
@Directive({
selector: '[myHighlight]',
})
export class ContentEditableDirective {
constructor(el: ElementRef) {
el.nativeElement.style.backgroundColor = 'yellow';
console.log(' el.nativeElement.style', el.nativeElement.style)
}
ngAfterContentInit(){
console.log('calling me again')}
}