举例简介AngularJS的内部语言环境
2015-06-17 00:00
1406 查看
AngularJS支持内置的国际化三种类型的过滤器货币,日期和数字。只需要根据国家的区域纳入相应的JS。默认情况下它处理浏览器的语言环境。例如,要使用丹麦语的语言环境,使用下面的脚本
<script src="https://code.angularjs.org/1.2.5/i18n/angular-locale_da-dk.js"></script>
使用丹麦语的语言环境实例
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。看到结果如下。
使用浏览器的语言环境示例
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。看到结果如下。
相关文章推荐
- angularJS 中$attrs方法使用指南
- 创建你的第一个AngularJS应用的方法
- AngularJS语法详解
- angularjs中的e2e测试实例
- AngularJS + Node.js + MongoDB开发的基于高德地图位置的通讯录
- AngularJS的内置过滤器详解
- angularJS结合canvas画图例子
- 教你用AngularJS框架一行JS代码实现控件验证效果
- AngularJS入门教程(零):引导程序
- AngularJS基础学习笔记之简单介绍
- AngularJS学习笔记之ng-options指令
- 整理AngularJS中的一些常用指令
- AngularJS入门教程(二):AngularJS模板
- ANGULARJS中用NG-BIND指令实现单向绑定的例子
- AngularJS入门教程之Hello World!
- AngularJS基础知识
- Angularjs编写KindEditor,UEidtor,jQuery指令
- AngularJS基础知识笔记之过滤器
- angularJS提交表单(form)
- angularJS 入门基础