Hi Mateusz, 

Thank you for your reply. The solution you made has the disadvantage of 
additional element in ng-repeat. 

I was about to post a solution I got from a coleague of mine:
http://jsfiddle.net/0k4w7zd0/7/

notice that the only change is:
element="collection[key]"
instead of
element="collection.{{key}}"

The truth is I got only the solution but no explanation why this works :). 
Anybody knows?
Is this a good approach or does it have any disadvantages?

Michał


On Thursday, October 16, 2014 10:32:53 AM UTC+2, Mateusz Skoczylas wrote:
>
> Hi Michał,
>
> I did small changes to Your fiddle and it seems to work now:
>
> ng-repeat is now changed and placed in outer div. Check this out:
>
> http://jsfiddle.net/0noruwjo/
>
> Mateusz
>
> W dniu wtorek, 14 października 2014 12:03:50 UTC+2 użytkownik Michał 
> Kocztorz napisał:
>>
>> Hi everyone, 
>>
>> I'm new to angular, so it's possible that what I'm trying to achieve is 
>> just wrong, but here's the problem:
>>
>> - I got parent directive containing some model in it's scope (list of 
>> objects, indexed by ID)
>> - I got child directive that is supposed to do something with an element 
>> of that list. It has isolated scope and is supposed to bind one of the 
>> elements in parent's collection using "element' attribute into it's scope.
>> - Parent directive uses ng-repeat to create child directive for every 
>> element of it's collection. Additionally it adds "element" attribute so the 
>> child directive could bind it's scope to one of the elements in collection.
>>
>> Problem is that when ng-repeat runs it seems to execute the child 
>> directive before it evaluates the "element" attribute. This makes the child 
>> directive to fail when binding the scope.
>>
>> It seems that ng-repeat should evaluate the "element" attribute first and 
>> then execute the child directive.
>>
>> I made a simplified example on jsfiddle: http://jsfiddle.net/0k4w7zd0/5/
>>
>> Thanks for any help in advance!
>> Michał
>>
>

-- 
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