With the help of AngularJS Filters method we create a currency filter function. In below example, We will first input two text box then we will declare first price of an article, after then will input quantity of article and finally get total price of an article.
<!DOCTYPE html>
<html>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="costCtrl">
Article: <input type="number" ng-model="quantity">
Price: <input type="number" ng-model="price">
<p>Total = {{ (quantity * price) | currency }}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('costCtrl', function($scope) {
$scope.quantity = 1;
$scope.price = 5.99;
});
</script>
</body>
</html>
0 Comment(s)