Home > Web Front-end > JS Tutorial > body text

An example of the internal language environment of AngularJS_AngularJS

WBOY
Release: 2016-05-16 15:54:26
Original
1260 people have browsed it

AngularJS supports built-in internationalization of three types of filters currency, date and number. Just include the corresponding JS according to the country's region. By default it handles the browser's locale. For example, to use the Danish locale, use the following script

<script src="https://code.angularjs.org/1.2.5/i18n/angular-locale_da-dk.js"></script>

Copy after login

Locale example using Danish
testAngularJS.html

<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.2.15/angular.min.js"></script>
 <script src="https://code.angularjs.org/1.2.5/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>

Copy after login

Results

Open textAngularJS.html in your web browser. See the results below.

2015617114029826.jpg (560×240)

Example of using browser locale
testAngularJS.html

<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.2.15/angular.min.js"></script>
 <!-- <script src="https://code.angularjs.org/1.2.5/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>

Copy after login

Results

Open textAngularJS.html in your web browser. See the results below.

2015617114048791.jpg (560×240)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!