简体   繁体   中英

AngularJS controller code not being evaluated in IE9

Thanks for looking.

I have some AngularJS code that is running fine in all browsers EXCEPT for IE9. IE8 even works fine, but not IE9.

For example, the breakpoint in the following screen grab will not be hit in IE9, though some regular JS code above it is hit:

在此处输入图片说明

Again, this works fine in IE8 even. Odder still, there are no JavaScript errors produced. Any ideas?

In case anyone else runs into this frustrating issue, for me the answer was this:

Create your opening body tag like this:

<body xmlns:ng="http://angularjs.org" id="ng-app">

Then, just before your closing body tag, place this script :

 <script>
         (function () {

                 angular.module('app');

                 angular.element(document).ready(function () {
                     angular.bootstrap(document, ['app']);
                 });                

         })();
        </script>

I have theories as to why this works, but in truth I am not certain. Hope it helps someone else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM