JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap.min.css">
<body ng-app="pangrams" class="ng-scope">
<div ng-controller="PangramCtrl" class="ng-scope">
<form ng-submit="add()">
<input class="form-control" ng-model="toAdd" placeholder="Add test strings here" />
</form>
<table class="table-striped table">
<tbody>
<tr>
<th>Phrase</th>
<th>Is Pangram</th>
<th>Letter Usage</th>
<th>Action</th>
</tr>
<tr ng-show="toAdd">
<td ng-bind="toAdd" class="ng-binding"></td>
<td ng-bind="toAdd | isPangram" class="ng-binding"></td>
<td ng-bind="toAdd | letterUsage" class="ng-binding"></td>
<td></td>
</tr>
<tr ng-repeat="line in lines" class="ng-scope">
<td ng-bind="line" class="ng-binding"></td>
<td ng-bind="line | isPangram" class="ng-binding"></td>
<td ng-bind="line | letterUsage" class="ng-binding"></td>
<td><a href="" ng-click="remove($index)">Delete</a>
</td>
</tr>
</tbody>
</table>
</div>
</body>
JavaScript
pan = angular.module("pangrams", [])
pan.controller("PangramCtrl", function PangramCtrl($scope) {
$scope.lines = ["The quick brown fox jumps over the lazy dog.", "Hi, /r/dailyprogrammer!"];
$scope.toAdd = "";
$scope.remove = function (index) {
$scope.lines.splice(index, 1);
}
$scope.add = function () {
if($scope.toAdd != ""){
$scope.lines.unshift($scope.toAdd)
$scope.toAdd = "";
}
}
})
pan.filter("isPangram", function () {
return function (input) {
input = input.toUpperCase()
var good = true;
angular.forEach("ABCDEFGHIJKLMNOPQRSTUVWXYZ", function (value) {
if (input.indexOf(value) == -1) {
good = false;
}
})
return good;
};
})
pan.filter("letterUsage", function () {
return function (input) {
input = input.toUpperCase()
var out = "";
angular.forEach("ABCDEFGHIJKLMNOPQRSTUVWXYZ", function (value) {
if (input.indexOf(value) != -1) {
if (out != "") {
out += ", "
}
out += value + ": " + (input.split(value).length - 1)
}
})
return out;
};
})