【发布时间】:2016-05-18 09:47:14
【问题描述】:
我不明白这两个 @Directive 和指令之间的区别:[HeroAppMainComponent] 在下面这种情况下
@Component({
selector: 'hero-app',
template: `
<h1>Tour of Heroes</h1>
<hero-app-main [hero]=hero></hero-app-main>`,
styles: ['h1 { font-weight: normal; }'],
directives: [HeroAppMainComponent]
})
和..
import { Directive, ElementRef, Input } from '@angular/core';
@Directive({ selector: '[myHighlight]' })
export class HighlightDirective {
constructor(el: ElementRef) {
el.nativeElement.style.backgroundColor = 'yellow';
}
}
【问题讨论】:
标签: typescript angular angular2-directives