angular兼容性问题的解决(ie6,ie7....,火狐,谷歌,360,等亲测兼容)

太过爱你忘了你带给我的痛 2022-05-22 01:45 395阅读 0赞

在使用angular包的时候,会遇到一些兼容性问题,下面的代码是一个解决了兼容性问题的一段代码。

代码如下:

  1. <!--[if lte IE 8]> <!DOCTYPE html><![endif]-->
  2. <html id="ng-app" class="ng-app:TestApp" ng-app="TestApp">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
  6. <title>ANGULAR TEST</title>
  7. <style>
  8. fieldset {
  9. border: black solid 1px;
  10. }
  11. .a{
  12. font-size:9pt;
  13. }
  14. .sky{
  15. background-color:#99ccff;
  16. }
  17. </style>
  18. <script src="/fs/scripts/angular.min.v125.js"></script>
  19. </head>
  20. <body ng-controller="TestCtrl">
  21. <h2 style="color:#009933;font-family:Arial">TESTTD</h2>
  22. <table cellpadding=1 cellspacing=2 style="width:600px;font-family:Arial" class="a">
  23. <tr>
  24. <td style="width:300px">ETB ID</th>
  25. <td style="width:300px">{
  26. {Test == null ? "---" : Test[0].TESTAAA}}</td>
  27. </tr>
  28. <tr>
  29. <td>Train Topography Counter</th>
  30. <td>{
  31. {Test == null ? "---" : Test[0].TESTBBB}}</td>
  32. </tr>
  33. </table>
  34. <br />
  35. <fieldset>
  36. <legend style="color: #009933;font-size:22px;font-family:Arial">List</legend>
  37. <table cellpadding=1 cellspacing=2 style="width:890px;font-family:Arial" class="a">
  38. <tr align="left" class="r5" style="background:#009933;color:#fff">
  39. <th style="width:370px">UUID</th>
  40. <th style="width:150px">Orientation</th>
  41. <th style="width:130px">Number</th>
  42. <th style="width:240px">Counter</th>
  43. </tr>
  44. <tr align="left" ng-if="Test != null" ng-repeat="entry in Test" ng-class="{'sky' : entry.TESTCCC == 'true'}">
  45. <td>{
  46. {entry.UUID}}</td>
  47. <td>{
  48. {entry.orientation}}</td>
  49. <td>{
  50. {entry.number}}</td>
  51. <td>{
  52. {entry.counter}}</td>
  53. </tr>
  54. </table>
  55. </fieldset>
  56. <script language="JavaScript">
  57. function ANGULAR(httpobj,scopeobj)
  58. {
  59. httpobj({
  60. method:'get',
  61. //添加时间是为了每次从浏览器读取时间使浏览器自己清除缓存
  62. url:'/cgi/json/Test.php?temptime=' + (new Date()).getTime(),
  63. timeout:2000,
  64. headers:{
  65. 'Content-Type':undefined
  66. },
  67. })
  68. .success(function(data) {
  69. scopeobj.Test = data.Testdatas;
  70. })
  71. .error(function() {
  72. scopeobj.Test = null;
  73. });
  74. }
  75. angular.module('TestApp', [])
  76. .controller('TestCtrl', function($scope, $http)
  77. {
  78. document.title = 'Test';
  79. $scope.title = 'Test';
  80. ANGULAR($http,$scope);
  81. setInterval(function() {
  82. ANGULAR($http,$scope);
  83. }, 2500);
  84. });
  85. </script>
  86. </body>
  87. </html>

下面几个重点部分注意一下:

1.

2.

3.

这个js包的版本可以去网上找一下应该有,我会将这个包上传的到CSDN。

4.

ng-controller标识了控制范围。

5.{ {Test == null ? “—-“ : Test[0].TESTAAA}}

显示部分,由于传过来的数据是存放在json数组中,所以去了Test【0】。

  1. { {entry.UUID}}

这部分的ng-repeat是用来迭代的,ng-class用于用返回来的数据控制显示的css。

发表评论

表情:
评论列表 (有 0 条评论,395人围观)

还没有评论,来说两句吧...

相关阅读