An Angular module with currency input directive (add commas as you type!)
Check out the package here https://github.com/CodySchaaf/CsCurrencyInput
A Pen by Cody Schaaf on CodePen.
An Angular module with currency input directive (add commas as you type!)
Check out the package here https://github.com/CodySchaaf/CsCurrencyInput
A Pen by Cody Schaaf on CodePen.
<div ng-app="myApp"> | |
<div ng-controller="Main as MainCtrl" class="container"> | |
<h5>Enter an amount below</h5> | |
<input type="text" cs-currency-input ng-model="MainCtrl.amount" allow-negatives="true" class="input-s form-control money" placeholder="$"/> | |
User facing value is formatted, while bound model is stored as a number: {{MainCtrl.amount}} | |
</div> | |
</div> |
declare var angular; | |
var myApp = angular.module("myApp",["csCurrencyInput"]) | |
class Ctrl { | |
public amount = ""; | |
constructor() { | |
} | |
} | |
myApp.controller('Main', Ctrl) |
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.14/angular.min.js"></script> | |
<script src="https://rawgit.com/CodySchaaf/CsCurrencyInput/master/app/build/index.js"></script> |
.money { | |
max-width: 300px; | |
&.ng-invalid:not(.ng-pristine) { | |
border-color: red; | |
} | |
} |
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" /> |