Can't bind to color since it isn't a known property of 'button'.
@Component({
selector: "nav-next",
template: `
<div class="nav-next-directive">
<button [color]="color" class="primary" [
</button>
</div>`
})
这个子指令使我们Angular2-RC4能够从父组件动态设置颜色。 Angular2-Final表示这不好。有什么想法吗?
答案 0 :(得分:4)
首次亮相ngModule
后,您必须在使用之前将Directive
添加到ngModule declarations
数组中:
@NgModule({
imports: [ BrowserModule ],
declarations: [ App, ColorDirective ],
bootstrap: [ App ]
})
export class AppModule {}
并确保您的Directive
selector
属于属性类型:
@Directive({
selector: "[color]"
})
以下是工作示例,如果您更改上述两项中的任何一项,您将收到该错误:http://plnkr.co/edit/ymUTyuMo9FsSORd9XI2H?p=preview