title: Anything like template references in AngularJS?
body: <p>I'm trying to create a form whose layout is entirely data driven.</p>
  
  <p>Example data source:</p>
  
  <pre><code>{
      title : "Form Test",
      fields : [{
              name : "FieldA",
              type : "string",
              value : "initial value"
          }, {
              name : "FieldB",
              type : "selection",
              options : ["1", "2", "3"],
              value : "2"
          }, {
              name : "FieldC",
              type : "struct",
              value :
              [{
                      name : "FieldC1",
                      type : "string",
                      value : "initial value"
                  }, {
                      name : "FieldC2",
                      type : "string",
                      value : "initial value"
                  }
              ]
          }
      ]
  }
  </code></pre>
  
  <p>I think can use ng-repeat and ng-switch to choose the form element depending on the 'type', however I get stuck when it comes to doing this recursively when I get to 'FieldC'.</p>
  
  <pre><code>&lt;span ng-switch on="field.type"&gt;
      &lt;div ng-switch-when="string"&gt;STRING: {{field.value}}&lt;/div&gt;
      &lt;div ng-switch-when="selection"&gt;SELECTION: {{field.value}}&lt;/div&gt;
      &lt;div ng-switch-when="struct"&gt;STRUCT: ????&lt;/div&gt;
      &lt;div ng-switch-default&gt;DEFAULT:{{field.value}}&lt;/div&gt;
  &lt;/span&gt;
  </code></pre>
  
  <p>Essentially I want a way that when I encounter a "struct" it recursively applies the ng-switch to the struct fields?  Is there any way to "reference" the template so it can be used in multiple places on the same page?  The support for template "partials" seems to need to be coordinated server-side via routes which seems like overkill here.  Is this something where I need to start digging into creating my own directives?</p>
  
  <p><strong>EDIT</strong> I just stumbled across <a href="http://jsfiddle.net/brendanowen/uXbn6/8/" rel="noreferrer">this</a> that looks like it has a decent chance of doing what I want (I have yet to properly test it), is that in the right direction?</p>