Angular2无法绑定到DIRECTIVE,因为它不是element的已知属性
我通过Angular CLI生成了新的@Directive,将其导入到我的app.module.ts中 import { ContenteditableModelDirective } from './directives/contenteditable-model.directive'; import { ChatWindowComponent } from './chat-window/chat-window.component'; @NgModule({ declarations: [ AppComponent, ContenteditableModelDirective, ChatWindowComponent, ... ], imports: [ ... ], ... }) 我尝试在我的组件(ChatWindowComponent)中使用 <p [appContenteditableModel] > Write message </p> 即使在指令内,只有Angular CLI生成的代码也是如此: import { Directive } from '@angular/core'; @Directive({ selector: '[appContenteditableModel]' }) export class ContenteditableModelDirective …