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", [])
.constant("MAX_LENGTH", 10)
.controller("textLengthLimitController", function ($scope, MAX_LENGTH) {
$scope.remaining = function () {
return MAX_LENGTH - $scope.text.length;
};
$scope.hasValidLength = function(){
return $scope.remaining() >= 0;
}
});