Chris Hayes
Chris Hayes

Reputation: 4033

How do you get dynamic html for directive AND recursion

I've been successful implementing the dynamic html for a directive: Angular.js directive dynamic templateURL

I've also successfully used the recursion example here: Recursion in Angular directives

I have failed to get them to work together, mainly because the second example will not compile the ng-include template.

any suggestions on creating dynamic directives recursively?

right now, nested questions don't bind.

background: I have a piece of json that contains questions and answers and questions recursively and i'm trying to dynamically create a form with said json. some are lists of checkboxes, some are just text, some are radio select

{
  "questions":[
    {
      "answers":[
        {
           "type":"text",
           "textvalue":"",
           "questions":[ ... etc ... ]
        }
      ]
    }
  ]
}

Upvotes: 0

Views: 33

Answers (1)

user3236101
user3236101

Reputation: 78

Recursion is function specific, so you can just recursively define the functions in your directive to handle what you are doing. The only difference in recursively solving your problem and solving it using an iterator is that the iterator uses a user defined stack.

Upvotes: 1

Related Questions