Hi Eric,

I've tried to assign the value as you suggest:

// ...
dcl.loadIntoLocation(MyDinamicClass, elementRef, anchor).then((componentRef)
 => {
   componentRef.instance.text = this.MainText;
});

It works, but only for the first assignment. If this.MainText changes, the 
value into the child component does not updates.
I would like to create a binding via code, something like this:

   componentRef.instance.text = new Binding(this.MainText);




On Thursday, December 3, 2015 at 8:40:31 PM UTC+1, Eric Martinez wrote:
>
> Hey Massimiliano,
>
> trying to answer your questions :
>
> - How I can programmatically setup a binding with the Components that I 
> have instantiated ?
>
> All the methods loadAsRoot, loadIntoLocation, loadNextToLocation are 
> promises that resolve to a reference to the component you just loaded 
> dynamically.
>
> So, let's assume this is your dynamic Component
>
>
> @Component({
>  template : '{{text}}'  // This will print 'My dynamic text' defined below
> })
> class MyDynamicClass {
>  text: string;
> }
>
>
>
>
> Then you can set a value for 'text' property by using the reference
>
>
> // ...
> dcl.loadIntoLocation(MyDinamicClass, elementRef, anchor).then((
> componentRef) => {
>    componentRef.instance.text = 'My dynamic text';
> });
>
>
>
>
>
> -How I can organize the loaded component on a layout? currently my main 
> template is just this line of code : <div #snapin> </div>
>
> I'm not really sure if I understood this question. How you organize your 
> layout is up to you. You can have things like this
>
>
> <div #snapin> 
>  <div #anothersnapin></div>
>  <div #sibling>
>     <div #children></div>
>  </div>
> </div>
>
>
> And you can load into those locations by using
>
> dcl.loadIntoLocation(MyDinamicClass, elementRef, 'snapin').then((
> componentRef) => {...});
> dcl.loadIntoLocation(MyDinamicClass, elementRef, 'anotherspin').then((
> componentRef) => {...});
> dcl.loadIntoLocation(MyDinamicClass, elementRef, 'sibling').then((
> componentRef) => {...});
> dcl.loadIntoLocation(MyDinamicClass, elementRef, 'children').then((
> componentRef) => {...});
> // etc...
>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to