大佬教程收集整理的这篇文章主要介绍了angularjs – Angular 2 RC 5 – 无法绑定到’…’,因为它不是’…’的已知属性,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@NgModule({ declarations: [ SignalComponent,BatteryComponent,MapsComponent ],imports : [ BrowserModule,FormsModule ],exports: [ SignalComponent,MapsComponent ] }) export class HelpersModule { }
电池组件如下所示:
@Component({ SELEctor: 'as-my-battery',template: ` <i class="fa fa-{{icon}}" aria-hidden="true"></i> ` }) export class BatteryComponent { @input() level: number; @Output() icon: String; // constructor() { } ngOnInit () { if (this.level < 5) { this.icon = 'battery-empty'; } else if (this.level >= 5 && this.level < 25) { this.icon = 'battery-quarter'; } else if (this.level >= 25 && this.level < 50) { this.icon = 'battery-half'; } else if (this.level >= 50 && this.level < 75) { this.icon = 'battery-three-quarters'; } else { this.icon = 'battery-full'; } } }
但是当我尝试使用输入级别的as-my-battery时,我收到此错误:
Error: Uncaught (in promisE): Template parse errors: Can't bind to 'level' since it isn't a kNown property of 'as-my-battery'. 1. If 'as-my-battery' is an Angular component and it has 'level' input,then verify that it is part of this module. 2. If 'as-my-battery' is a Web Component then add "CUSTOM_ELEMENTS_scheR_361_11845@A" to the '@NgModule.scheR_361_11845@a' of this component to suppress this message. (""checkBox" name={{data.namE}} value={{data.namE}}> {{data.namE}} <as-my-battery [ERROR ->][level]='data.battery'></as-my-battery> <as-my-signal [level]='data.signal'></as-"): a@19:35
有其他人这些问题,并最终解决这个问题?
我也找到了这个话题,但这不是我的答案:Can’t bind to ‘data’ since it isn’t a known property of ‘teach-data’
最后,这是我的应用程序的引导程序:
@NgModule({ declarations: [ AppComponent ],imports: [ NavbarModule,LoginModule,HelpersModule,KaartModule,LijstModule,LogsModule,InstellingenModule,StatistiekenModule,routIng ],providers: [ APP_PROVIDERS,appRoutIngProviders ],bootstrap: [ AppComponent ] }) export class AppModule { }
电池组件需要在LijstComponent中使用,模块声明:
@NgModule({ declarations: [ LijstComponent ],imports: [ BrowserModule,HelpersModule ],exports: [ LijstComponent ] }) export class LijstModule { }
LijstComponent:
@Component({ SELEctor: 'as-lijst',providers: [Dataservice,Markerservice,Alertservice],templateUrl: 'app/lijst/lijst.html',}) export class LijstComponent { ... }
和html的片段(数据是循环的* ngFor):
<as-my-battery [level]='data.battery'></as-my-battery>
以上是大佬教程为你收集整理的angularjs – Angular 2 RC 5 – 无法绑定到’…’,因为它不是’…’的已知属性全部内容,希望文章能够帮你解决angularjs – Angular 2 RC 5 – 无法绑定到’…’,因为它不是’…’的已知属性所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。