Mark I saw your example and it is awesome however when i try to load data 
using a resource from an API, it will not work!!!
This is what my data looks like from the API

   - 
   {
      - ID: "1",
      - type: "Folder",
      - name: "Parent",
      - children: []
      }
   


        module.factory('TreeView', function ($resource) {
            return $resource('/api/TreeView/:Id', {}, {
                show: { method: 'GET', isArray: false },
                update: { method: 'PUT', params: { id: '@id' } },
                delete: { method: 'DELETE', params: { id: '@id' } }
            })
        });

        module.controller('TreeCtrl', function ($scope, TreeView) {

            $scope.treeFamily = TreeView.query();

            //$scope.treeFamily = {
            //    name: "Parent",
            //    children: [{
            //        name: "Child1",
            //        children: [{
            //            name: "Grandchild1",
            //            children: []
            //        }, {
            //            name: "Grandchild2",
            //            children: []
            //        }, {
            //            name: "Grandchild3",
            //            children: []
            //        }]
            //    }, {
            //        name: "Child2",
            //        children: []
            //    }]
            //};
        });


Any thoughts? When i uncomment the DATA it works 100% perfect! but when i 
try to get the data from my api it does not :(



On Wednesday, September 4, 2013 1:59:43 AM UTC-7, Mark Lagendijk wrote:
>
> Indeed a very helpful thread. I took Matts fiddle and abstracted the 
> recursion functionality into a service <http://jsfiddle.net/xUsCc/1/>.
> I like this solution best because:
>
>    1. You keep your html clean
>    2. You keep your directives clean
>
> module.factory('RecursionHelper', ['$compile', function($compile){
>>     var RecursionHelper = {
>>         compile: function(element){
>>             var contents = element.contents().remove();
>>             var compiledContents;
>>             return function(scope, element){
>>                 if(!compiledContents){
>>                     compiledContents = $compile(contents);
>>                 }
>>                 compiledContents(scope, function(clone){
>>                     element.append(clone);
>>                 });
>>             };
>>         }
>>     };
>>
>
> On Thursday, May 23, 2013 11:58:22 PM UTC+2, Matt Hardy wrote:
>>
>> This thread was extremely helpful. I found it when searching for a way to 
>> recursively reference a directive inside itself for nested comment replies 
>> on a blog post document.
>>
>> I edited the fiddle from Anders slightly (incorporating Helen's tip) and 
>> added some CSS for clarity. I streamlined the markup so there are only 
>> nested "<tree>" directives without the helper  "<recursive>" wrapper.
>>
>> http://jsfiddle.net/n8dPm/
>>
>> Hope this helps someone trying to use a recursive AngularJS directive!
>>
>> Matt
>>
>

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