JSFiddle - React, Tailwind, and code Playground
by benweizhu
HTML
<body ng-app="textSender">
<div ng-controller="textLengthLimitController">
<textarea ng-model="text"></textarea> <span>{{remaining()}}</span>
<input type="button" ng-disabled="!hasValidLength()" value="send" />
</div>
</body>
JavaScript
angular.module('textSender', [])
.controller('textLengthLimitController', function ($scope) {
var MAX_LENGTH = 10;
$scope.remaining = function () {
return MAX_LENGTH - $scope.text.length;
};
$scope.hasValidLength = function () {
return $scope.remaining() >= 0;
};
});