I want to make table directive, but i'm not sure how to do it. Here is my source code.
Directive:
InterfaceModule.directive('gList', function() {
return {
restrict: 'AEC',
transclude: true,
templateUrl: 'interface/gList.html'
};
});
gList.html:
<table class="table table-condensed">
<tr>
<td style="width: 20px">
<span class="icon-f-gear-small"></span>
</td>
<td ng-transclude>
</td>
</tr>
</table>
controller:
App.controller('ResultController', ['$scope', function($scope) {
$scope.testItems = ['element 1', 'element 2', 'element 3']
}])
html code:
<div ng-controller="ResultController">
<g-list>
<a href="#" ng-click="someFunction()">{{item}}</a>
</g-list>
</div>
I need to use ng-repeat in <tr> tag, although I don't want to use it in directive template, I want it to use in my main html file. If I use it in g-list tag (<g-list ng-repeat="item in testItems">) I am getting seperate table to each element in array, I need one table and number of rows which is equal to array size (in this case one table with 3 rows). So the question would be how to change my directive that works as I explained. Thanks in advance!
UPDATE
Thanks for answer. Now it's a bit more clear, but I still have several questions. The main Idea is that i want to have in final something like this:
<g-list icon="gear-small">
<g-entry function="someFunction()">Sąrašo elementas 1</g-entry>
<g-entry link="/some/url" count="20">Sąrašo elementas 2</g-entry>
<g-entry link="/some/url" disabled="Netinkama objekto būsena">Sąrašo elementas 3</g-entry>
</g-list>
There will be entries where i will need to call function and there will be entries where I will have to go to some url on clik event.