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

使用瀏覽器的語言環(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>
結果
在Web瀏覽器打開textAngularJS.html??吹浇Y果如下。

相關文章
詳解在 Angular 項目中添加 clean-blog 模板
本篇文章主要介紹了詳解在 Angular 項目中添加 clean-blog 模板,非常具有實用價值,需要的朋友可以參考下2017-07-07
AngularJS ng-bind-html 指令詳解及實例代碼
本文主要是對AngularJS ng-bind-html 指令知識的詳細講解,并附代碼實例,有需要的小伙伴可以參考下2016-07-07
Angular2中如何使用ngx-translate進行國際化
本篇文章主要介紹了Angular2中使用ngx-translate進行國際化,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-05-05
angularJS 發(fā)起$http.post和$http.get請求的實現方法
本篇文章主要介紹了angularJS 發(fā)起$http.post和$http.get請求的實現方法,分別介紹了$http.post和$http.get請求的方法,有興趣的可以了解一下2017-05-05

