Hi Daniel, thanks for your answer. That is the solution, I used, but in this case, I'm only able to pass some data to properties of the component. I'm wondering, if there is a way, to set up a "real" property-binding. Currently, I see two workaround for doing this:
1. Use Life-Cycle-Hooks to pass changed properties to the dynamically created child component 2. Write a custom wrapper component with a template that consists of a dynamically created html-string that sets up the binding via []-syntax (see the "class-declaration-with-factory-function-trick" at the end of [1]). But both solutions don't feel "right" for me, so I'm wondering, whether there is a better, streight forward solution to this ... Wishes, Manfred [1] http://stackoverflow.com/questions/32340641/angular-2-equivalent-of-ng-bind-html-sce-trustashtml-and-compile/32341540#32341540 Am Dienstag, 22. Dezember 2015 21:35:03 UTC+1 schrieb Daniel: > > Hi, > > This is how I've solved it on my end > > @Component({ > selector: 'test', > template: 'TEST!' > }) > class Test {} > > class Loader{ > ... > ngOnInit() { > var type = 'test' > var clazz = type.camelize() // clazz = 'Test' > this.loader.loadIntoLocation(eval(clazz), this.elementRef, > 'dynamicInstance').then((ref) => { > ref.instance.data = this.options > }) > } > } > > > Hope that helps. > > On Monday, 21 December 2015 23:57:25 UTC+1, Manfred Steyer wrote: >> >> Hi Eric, >> >> now, I've looked into this and I have 2 questions: >> >> 1. The following sample creates a new Component-Instance with >> loadIntoLocation and assignes a model to it. But how to set up bindings >> (property, event, two-way)? >> >> this.loader.loadIntoLocation(DynamicComponent, this.element, 'attach') >> then((res) => {res.instance.model = model; this.savedComp = res;}); >> >> 2. The solution at the end of [1] declares a CompiledComponent-Class >> within the constructor. Somehow, that looks like a work-around. Is there an >> other solution for this? >> >> [1] >> http://stackoverflow.com/questions/32340641/angular-2-equivalent-of-ng-bind-html-sce-trustashtml-and-compile/32341540#32341540 >> >> Wishes, >> Manfred >> >> Am Samstag, 19. Dezember 2015 20:12:08 UTC+1 schrieb Manfred Steyer: >> >>> Thanks for the hint! >>> >>> Best wishes, >>> Manfred >>> >>> Am Freitag, 18. Dezember 2015 21:45:43 UTC+1 schrieb Eric Martinez: >>> >>>> Manfred, >>>> >>>> you are looking for DynamicComponentLoader >>>> <https://angular.io/docs/ts/latest/api/core/DynamicComponentLoader-class.html>. >>>> >>>> You can check these questions to see some usage of it in SO >>>> http://stackoverflow.com/search?tab=relevance&q=dynamiccomponentloader >>>> >>> -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To post to this group, send email to angular@googlegroups.com. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.