AngularJS - Các chức năng quốc tế hóa AngularJS cung cấp sẵn các chức năng quốc tế hóa với 3 kiểu filter là currency, date và number.. Chúng ta chỉ cần kết hợp đoạn js tương ứng với theo
Trang 1AngularJS - Các chức năng quốc tế hóa AngularJS cung cấp sẵn các chức năng quốc tế hóa với 3 kiểu filter là currency, date và number Chúng ta chỉ cần kết hợp đoạn js tương ứng với theo vị trí tùy Quốc gia Mặc định nó sẽ gắn với ví trị trong trình duyệt web Ví dụ, khi sử dụng ví trí ở Đan Mạch, bạn sử dụng đoạn script sau đây:
<script src="https://code.angularjs.org/1.2.5/i18n/angular-locale_da-dk.js"></script>
testAngularJS.jsp
<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="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="https://code.angularjs.org/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>
Trang 2</body>
</html>
Mở trang textAngularJS.jsp trong một trình duyệt web và xem kết quả
testAngularJS.jsp
<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="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<! <script src="https://code.angularjs.org/1.3.14/i18n/angular-locale_da-dk.js"></script> >
<script>
Trang 3var mainApp = angular.module("mainApp", []);
mainApp.controller('StudentController', function($scope) {
$scope.fees = 100;
$scope.admissiondate = new Date();
$scope.rollno = 123.45;
});
</script>
</body>
</html>
Mở trang textAngularJS.jsp trong một trình duyệt web và xem kết quả