AngularJS支持內(nèi)置的國際化三種類型的過濾器貨幣,日期和數(shù)字。只需要根據(jù)國家的區(qū)域納入相應(yīng)的JS。默認(rèn)情況下它處理瀏覽器的語言環(huán)境。例如,要使用丹麥語的語言環(huán)境,使用下面的腳本
<script src="https://code.angularjs.org/1.2.5/i18n/angular-locale_da-dk.js"></script>
使用丹麥語的語言環(huán)境實(shí)例
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>結(jié)果
在Web瀏覽器打開textAngularJS.html。看到結(jié)果如下。

AngularJS Internalization 使用瀏覽器的語言環(huán)境示例
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>結(jié)果
在Web瀏覽器打開textAngularJS.html。看到結(jié)果如下。

以上就是對(duì)AngularJS 國際化的資料整理,后續(xù)繼續(xù)整理相關(guān)資料,謝謝大家對(duì)本站的支持!
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注