Running AngularJS App on Internet Explorer 7

强颜欢笑 提交于 2019-11-29 20:30:31

1) Add id="ng-app" to your body tag.

<body ng-app="myApp" id="ng-app">

  2) Inform your users/client it's 2013.

Roberto Linares

After some more reading I could make it work.

The problem with IE7 was the bootstrapping. It was not firing any! so I made a manual initialization as shown in this page and it worked.

This is the code I added to the HTML assuring it will only fire on Internet Explorer 8 or lower (because if I fire it for all browsers some event handlers fire twice for non-ie browsers):

<!--[if lte IE 8]>
<script type="text/javascript">
    $(document).ready(function() {
        angular.bootstrap(document);
    });
</script>
<![endif]-->

The $document.ready() part is the jQuery way to be sure this code will be executed when everything on the body has been loaded but since I was using jQuery on my site I took advantage of it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!