问题描述
我想动态加载指令,因为我想为不同的客户端加载不同的指令,但是父组件将是相同的,只是子组件会根据客户端而改变。
@Component({
selector: 'app-root',template: `
<h1>Reusable Angular Components - Tabs</h1>
<ngx-tabs>
<ngx-tab tabTitle="Hero List">
<h1>Hero List</h1>
<div [className]="key" [heroes]="heroes"></div>
</ngx-tab>
<ngx-tab tabTitle="Hero">
<h1>Hero</h1>
</ngx-tab>
</ngx-tabs>
`,})
export class AppComponent implements OnInit {
heroes;
public key = 'app-heroes-list'
constructor(private heroesService: HeroesService) {}
ngOnInit() {
this.heroesService.getHeroes().subscribe(data => {
this.heroes = data;
});
}
}
compiler.js:215 Uncaught`enter code here` Error: Template parse errors:
Can't bind to 'heroes' since it isn't a kNown property of 'div'. ("
<ngx-tab tabTitle="Hero List">
<h1>Hero List</h1>
<div [className]="key" [ERROR ->][heroes]="heroes"></div>
</ngx-tab>
<ngx-tab tabTitle="Hero">
"): ng:///AppModule/AppComponent.html@5:31
at SyntaxError (compiler.js:215)
at TemplateParser.push../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse (compiler.js:14702)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._parseTemplate (compiler.js:22709)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileTemplate (compiler.js:22696)
at compiler.js:22639
at Set.forEach (<anonymous>)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents (compiler.js:22639)
at compiler.js:22549
at Object.then (compiler.js:206)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:22548)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)