Hello Sander,

At first, I would like to thank you for quick reply and answer, however, i 
don't get it one point. Why do i need the index of actions instead of 
actions id? I can use actions id which is absolutely fine for me.

On Wednesday, 1 July 2015 10:29:38 UTC+3, Sander Elias wrote:
>
> Hi Can,
>
> I couldn't resist playing with it, I might as well share the result 
> <http://plnkr.co/edit/hHsH40L3wUYLZ3dl5Y3T?p=preview>with you :)
>
> Has nothing to do with angular whatsoever. Rebuild your sample into a 
> recursive function:
>
>     vm.testData = function() {
>         vm.actionTest = [];  
>         traverse(vm.data);
>
>         function traverse(arr) {
>             arr.forEach(checkOut);
>
>             function checkOut(item) {
>                 vm.actionTest.push(handle(item));
>                 item.childs && traverse(item.childs); // to lazy to write 
> an if ;)
>             }
>         }
>
>         function handle(source) {
>             return {
>                 ID: source.id,
>                 Depth: source.depth,
>                 Actions: source.actions.map(indexForChecked).filter(
> isChecked)
>             };
>
>             function indexForChecked(action, index) { return action.isChecked 
> ? index : -1; }
>             function isChecked(action) { return action !== -1; }
>         }
>     };
>
>
> Does that help you a bit?
>
> Regards
> Sander
>

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