JSFiddle - React, Tailwind, and code Playground
by ItsLeeOwen
HTML
<script src="http://underscorejs.org/underscore-min.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css">
<span ng-controller="Headlines">
<div ng-repeat="story in headlines | orderBy:[sort, '-created']">{{story.name}} - {{story.order}} - {{story.created}}</div>
</span>
JavaScript
console.clear();
var module = angular.module('app', []);
function Story(name) {
var self = this;
this.name = name;
this.order = Math.floor(Math.random() * 10);
this.created = Math.floor(Math.random() * 1000);
self.getOrder = function(key) {
return -self.order;
}
}
function Headlines($scope) {
$scope.category = 'picks';
$scope.headlines = [new Story('one'),
new Story('two'),
new Story('three')];
$scope.sort = function(story) {
return story.getOrder($scope.category);
}
}