Running AngularJS App on IE7

IE7需要額外在body宣告宣告id和ng-app屬性:

1
<body id="ng-app" ng-app="myapp">

盡量使用class、attribute的寫法,例如:

1
2
<div class="ng-view"></div>
<div ng-view></div>

若要在IE7使用angular自訂定義的tag,而不採用上述方式,如下:

1
<ng-view></ng-view>

需要先執行以下script,可參考官方說明

1
2
3
4
5
6
7
8
9
10
11
12
<!--[if lte IE 8]>
<script>
document.createElement('ng-include');
document.createElement('ng-pluralize');
document.createElement('ng-view');

// Optionally these for CSS
document.createElement('ng:include');
document.createElement('ng:pluralize');
document.createElement('ng:view');
</script>
<![endif]-->

在IE8、IE7使用angular.fromJson,需額外include script,http://bestiejs.github.com/json3/

1
2
3
<!--[if lte IE 8]>
<script src="/static/js/libs/json3.min.js"></script>
<![endif]-->