JSFiddle - React, Tailwind, and code Playground

by benweizhu

HTML

<body ng-app>
    <div ng-controller="textLengthLimitController">
        <textarea ng-model="text"></textarea> <span>{{remaining()}}</span>
        <input type="button" ng-disabled="!hasValidLength()" value="send" />
    </div>
</body>

JavaScript

var MAX_LENGTH = 10;

function textLengthLimitController($scope) {

    $scope.remaining = function () {
        return MAX_LENGTH - $scope.text.length;
    };

    $scope.hasValidLength = function () {
        return $scope.remaining() >= 0;
    };

}