加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

举例简介AngularJS的内部语言环境

发布时间:2020-12-14 22:20:28 所属栏目:资源 来源:网络整理
导读:AngularJS支持内置的国际化三种类型的过滤器货币,日期和数字。只需要根据国家的区域纳入相应的JS。默认情况下它处理浏览器的语言环境。例如,要使用丹麦语的语言环境,使用下面的脚本 script src="https://code.angularjs.org/1.2.5/i18n/angular-locale_da

 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。看到结果如下。

2015617114029826.jpg (560×240)

 使用浏览器的语言环境示例
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",function($scope) {
   $scope.fees = 100;
 $scope.admissiondate = new Date();
   $scope.rollno = 123.45;
  });
  
 </script>
</body>
</html>

结果

在Web浏览器打开textAngularJS.html。看到结果如下。

2015617114048791.jpg (560×240)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读