This time I will bring you AngularJS to implement the price calculation function. What are the precautions for AngularJS to implement the price calculation function? The following is a practical case. Let’s take a look. .
The code is as follows:
<!DOCTYPE html> <html lang="en" ng-app> <head> <meta charset="UTF-8"> <title>www.jb51.net angular计算总价</title> <link rel="stylesheet" type="text/css" href="style.css" rel="external nofollow" > <script type="text/javascript" src="../libs/angular.min.js"></script> </head> <body> <table> <tr><td>单价:</td><td><input type="text" ng-model="price"></td></tr> <tr><td>数量:</td><td><input type="text" ng-model="number"></td></tr> <tr><td>总价:</td><td>{{price*number|currency:'¥'}}</td></tr> </table> </body> </html>
There are a few points to note:
<script type="text/javascript" src="../libs/angular.min.js"></script>
Introduction to angularjs Script;<html lang="en" ng-app>
model="price"> The data comes from the input with ng-model="price"
/ng-model="number"
attribute Box;
filter
, which can format numbers into currency. If not specified, the default is $. I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website! Recommended reading:
vue-cli How to configure lib-flexible rem mobile terminal adaptation
vue-cli Detailed explanation of usage
The above is the detailed content of AngularJS implements price calculation function. For more information, please follow other related articles on the PHP Chinese website!