Skip to content

Instantly share code, notes, and snippets.

@mdonkers
Created January 5, 2014 16:45
Show Gist options
  • Save mdonkers/8270527 to your computer and use it in GitHub Desktop.
Save mdonkers/8270527 to your computer and use it in GitHub Desktop.
AngularJS Directives - Using value in HTML attribute directly instead of needing to store on $scope.
myApp.directive('statsList', function () {
return {
restrict: 'E',
scope: {
items: '=listType',
orderBy: '@'
},
templateUrl: 'partials/partial1.html'
};
});
<stats-list list-type="topDuration" order-by="duration"></stats-list>
<stats-list list-type="latest" order-by="start"></stats-list>
<table class="table table-condensed">
<thead>
<tr>
<th>Sensor Id</th>
<th>Start</th>
<th>Duration</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in items | orderBy:'value.' + orderBy:reverse=true">
<td>{{item.value.sensorId}}</td>
<td>{{item.value.start | date:'dd/MM @ H:mm'}}</td>
<td>{{item.value.duration | msToSec | number | secAppendix}}</td>
</tr>
</tbody>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment