I have a list which can contain different types of things that need a different template / controller. Whats the best way to do this in angular js.
The best i've come up with so far is to have the template as part of the ng-repeat data.
<ul>
<li ng-repeat="foo in list">
<div ng-include src="'partials/'+foo.template+'.template.html'">
</div>
</li>
</ul>
where the list is something like.
[{template:'foo',data:{...}},{template:'bar',data:{...}}]
Looks good to me, you don't even need the <div>
tags since you can attach ng-include to the <li>
tags (I think).
You can use a directive like this http://onehungrymind.com/angularjs-dynamic-templates/