JSFiddle - React, Tailwind, and code Playground
by vaiism
HTML
<div ng-app="app" ng-controller="ctrl">
<p>
Enter a string into the "number" field. Clicking any of the buttons
will not clear the field.
</p>
<p>
Enter a number into the "number" field. Clicking any of the buttons
will clear the field.
</p>
<input type="number" ng-model="someValue" placeholder="Enter a number"/>
<button type="button" ng-click="set('hello, world!')">Set to Hello, World!</button>
<button type="button" ng-click="set(undefined)">Set to undefined</button>
<button type="button" ng-click="set('')">Set to empty string</button>
<button type="button" ng-click="set(0)">Set to zero</button>
</div>
CSS
button {
display: block;
}
JavaScript
angular.module('app', [])
.controller('ctrl', function($scope) {
$scope.someValue = undefined;
$scope.set = function(val) {
$scope.someValue = val;
};
});