3

I am trying to bind data to an ng-container that is in Angular 4 now. The component loads fine, but when I add [componentData]="testing" I get error

<ng-container *ngComponentOutlet="components.name"  [componentData]="testing">
</ng-container>

Error

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>

Is it true you can't bind data to ngComponentOutlet?

2

1 Answer 1

0

To fix this you can create a custom component

'custom-ng-container'

@Input() componentName : any;
@Input() componentData : any[];

HTML will look like

<ng-container *ngComponentOutlet="componentName" >

</ng-container>

You should be using in your parent component as

<custom-ng-container [componentName]="components.name"  [componentData]="testing"> </custom-ng-container>
Sign up to request clarification or add additional context in comments.

4 Comments

So the answear is that you can't :(
yup. you have limitations of using *ngContainer
Can you updated ur answear please to that it is not possible
@Aravind i need to read componentData values in loaded component page not in 'custom-ng-container' custom component.Ex: <custom-ng-container [componentName]="components.name" [componentData]="testing"> </custom-ng-container> components:[{name:Page.component}]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.