Я пытаюсь динамически добавлять разные директивы в ng-repeat, но вывод не интерпретируется как директивы.
Я добавил здесь простой пример: http://plnkr.co/edit/6pREpoqvmcnJJWzhZZKq
Контроллер:
$scope.colors = [{name:"red"}, {name: "blue"}, {name:"yellow"}];
Директива
app.directive("red", function () {
return {
restrict: 'C',
template: "RED directive"
}
});
Html:
<ul>
<li ng-repeat="color in colors">
<span class="{{color.name}}"></span>
</li>
</ul>
Как мне сделать angular выбрать директиву, указанную в class
, которая выводится через ng-repeat?