源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

AngularJS国际化详解及示例代码

  • 时间:2020-12-05 18:30 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:AngularJS国际化详解及示例代码
AngularJS支持内置的国际化三种类型的过滤器货币,日期和数字。只需要根据国家的区域纳入相应的JS。默认情况下它处理浏览器的语言环境。例如,要使用丹麦语的语言环境,使用下面的脚本
<script src="https://code.angularjs.org/1.2.5/i18n/angular-locale_da-dk.js"></script> 
[b]使用丹麦语的语言环境实例[/b] 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>
[b]结果[/b] 在Web浏览器打开textAngularJS.html。看到结果如下。 [img]http://files.jb51.net/file_images/article/201608/201681883045742.jpg?20167188317[/img] [b]AngularJS Internalization 使用浏览器的语言环境示例[/b] 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>
[b]结果[/b] 在Web浏览器打开textAngularJS.html。看到结果如下。 [img]http://files.jb51.net/file_images/article/201608/201681883208484.jpg?201671883223[/img] 以上就是对AngularJS 国际化的资料整理,后续继续整理相关资料,谢谢大家对本站的支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部