简体   繁体   English

Angular2:在@Component({.....}) 中找不到“指令”属性

[英]Angular2: 'directives' property not found in @Component({.....})

I created a directive to auto-grow a textbox but when i implemented it to the component i'm getting the error.我创建了一个自动增长文本框的指令,但是当我将它实现到组件时,我收到了错误。

myAppComps.ts myAppComps.ts

在此处输入图片说明

NPM RUN BUILD NPM 运行构建
在此处输入图片说明

auto-grow.directives.ts auto-grow.directives.ts
在此处输入图片说明

myAppComps.html myAppComps.html
在此处输入图片说明

package.json:包.json:
在此处输入图片说明

If you are using RC6 and up - you need to use @NgModule to declare the directives (under 'declarations'):如果您使用的是 RC6 及更高版本 - 您需要使用 @NgModule 来声明指令(在“声明”下):

@NgModule({
  imports:      [ BrowserModule],
  declarations: [ AppComponent,PeopleListComponent ],  //<----here
  providers:    [],      
  bootstrap:    [ AppComponent ]
})

Source 来源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM