i'm struggling with Angular. I can't define the "best practice" for what i want.
I need to display one or many array. I define the HTML as this :
<form ng-show="searchtab">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-search"></i></div>
<input type="text" class="form-control" placeholder="Search da Fish" ng-model="searchFish">
</div>
</div>
</form>
<table class="table table-bordered table-striped">
<thead>
<tr>
<td ng-repeat="item in dataTabTitle">
<a ng-click="$parent.sortType = item.column; $parent.sortReverse = !sortReverse">
{{ item.title}}
<span ng-show="sortType == '{{item.column}}' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == '{{item.column}}' && sortReverse" class="fa fa-caret-up"></span>
</a>
</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in dataTab | orderBy:sortType:sortReverse | filter:searchFish">
<td ng-repeat="(key, value) in item">{{value}}</td>
</tr>
</tbody>
</table>
It work for a single array. CodePen exemple Here : http://codepen.io/anon/pen/gpXwbz
Now : I would like it to be callable as a directive. like <myArrayDisplay searchtab="sth" dataTabTitle="sthElse" dataTab="sthOther">.
My question so far : Is directive the "good way" for doing this? I also want to call it without having all this variable on $scope, just giving them to the directive directly.