【发布时间】:2017-10-28 11:06:24
【问题描述】:
我正在尝试将数据绑定到 Angular 4 中的 ng-container。 组件加载正常,但是当我添加 [componentData]="testing" 时出现错误
<ng-container *ngComponentOutlet="components.name" [componentData]="testing">
</ng-container>
错误
Error: Template parse errors:
Can't bind to 'componentData' since it isn't a known property of 'ng-container'.
1. If 'componentData' is an Angular directive, then add 'CommonModule' to the '@NgModule.imports' of this component.
2. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("'Textarea' ">
<ng-container *ngComponentOutlet="widget.widgetComponent.component" [ERROR ->][componentData]="testing">
</ng-container>
</div>
真的不能绑定数据到ngComponentOutlet吗?
【问题讨论】:
-
您拥有
ng-container,用于template。[componentData]是一个自定义的@Input()属性,不能用作您的输入。
标签: angular data-binding