0

I have a component which wanted to pass a several parameter:

 <sentence [sentence]="text.title" [selectedWord]="selectedWord" (selectionChanged)="selectionChanged($event)"></sentence>

I'm creating a component dynamically using this code:

 addComponent() {
        this.compiler.resolveComponent(TaskHeaderComponent).then((factory) =>

        this.cmpRef = this.viewContainer.createComponent(factory, 0, this.viewContainer.injector));
    }

How i can pass to created component:

  1. inputs: [sentence]="text.title" [selectedWord]="selectedWord"
  2. outputs function: (selectionChanged)="selectionChanged($event)"

TIA

2
  • 1
    stackoverflow.com/questions/37368107/… Commented Jul 20, 2016 at 15:37
  • 1
    yes, only way - to get access to cmpRef.instance and set inputs in code, subscribe for outputs manually also.. Commented Jul 20, 2016 at 16:05

1 Answer 1

1

There is no binding support dor dynamically added elements, but you can do it imperatively

this.cmpRef.instance.sentence = ...
this.cmpRef.instance.selectionChange.subscribe(...)
Sign up to request clarification or add additional context in comments.

Comments

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.