1

I'm using angular-foundation tabset and need to have a few tabs with the same structure. Say the repeating content is only used in this template so I don't want to create a new file for it, while it's a bit too much for me to feel comfortable about copy&paste.

I'm wondering if it's possible to have the "subtemplate" within the same file? How could I do it?

Below is a pseudo code showing what I want to achieve:

<!-- subtemplate parts -->
<toInclude name="workerTable">
  <tr ng-repeat="worker in workers">
    <td>{{worker.name}}</td><td>{{worker.id}}</td>...
  </tr>
</toInclude>
<!-- end of subtemplate parts -->

<tabset>
  <tab title="IT department" select="workers = itWorkers">
    <include src="workerTable"></include>
    ...stuff for IT workers only...
  </tab>
  <tab title="Sales department" select="workers = salesWorkers">
    <include src="workerTable"></include>
    ...stuff for sales workers only...
  </tab>
  ....
</tabset>
Xun Yang
  • 4,209
  • 8
  • 39
  • 68
  • 1
    How about using ng-include? https://docs.angularjs.org/api/ng/directive/ngInclude – jbrown Apr 14 '16 at 13:35
  • ng-include only includes templates that are in individual files, as far as I understand? I wish to have the subtemplate in the same file as the main template – Xun Yang Apr 14 '16 at 13:43
  • Why do you need to have them in the same file? – jbrown Apr 14 '16 at 13:57
  • The subtemplate is only used in one template, and it's not very long. Feels a bit too much to create a new file just for it. I can copy paste it a few times, just wondering if there's a way to avoid so. – Xun Yang Apr 14 '16 at 14:17

0 Answers0