编辑这个页面须要登录或更高权限!
AngularJS支持三种类型过滤器的内置国际化:货币、日期和数字。我们只需要根据国家的语言环境合并相应的java脚本。默认情况下,它考虑浏览器的区域设置。例如,对于丹麦语区域设置,请使用以下脚本-
<script src = "https://code.angularjs.org/1.2.5/i18n/angular-locale_da-dk.js"> </script>
<html> <head> <title>Angular JS Forms</title> </head> <body> <h2>AngularJS Sample Application</h2> <div ng-app = "mainApp" ng-controller = "StudentController"> {{fees | currency }} <br/><br/> {{admissiondate | date }} <br/><br/> {{rollno | number }} </div> <script src = "https://cdn.staticfile.org/angular.js/1.3.14/angular.min.js"></script> <script src = "https://cdn.staticfile.org/angular.js/1.3.14/i18n/angular-locale_da-dk.js"></script> <script> var mainApp = angular.module("mainApp", []); mainApp.controller('StudentController', function($scope) { $scope.fees = 100; $scope.admissiondate = new Date(); $scope.rollno = 123.45; }); </script> </body> </html>测试看看‹/›
输出结果
在网络浏览器中打开文件testAngularJS.htm并查看结果。
<html> <head> <title>Angular JS Forms</title> </head> <body> <h2>AngularJS Sample Application</h2> <div ng-app = "mainApp" ng-controller = "StudentController"> {{fees | currency }} <br/><br/> {{admissiondate | date }} <br/><br/> {{rollno | number }} </div> <script src = "https://cdn.staticfile.org/angular.js/1.3.14/angular.min.js"></script> <!-- <script src = "https://cdn.staticfile.org/angular.js/1.3.14/i18n/angular-locale_da-dk.js"></script> --> <script> var mainApp = angular.module("mainApp", []); mainApp.controller('StudentController', function($scope) { $scope.fees = 100; $scope.admissiondate = new Date(); $scope.rollno = 123.45; }); </script> </body> </html>测试看看‹/›
输出结果
在网络浏览器中打开文件testAngularJS.htm并查看结果。