문제

What's the best strategy for excluding an Angular module from loading in IE8?

I have an app that works acceptably well in IE8, except for one module, https://github.com/compact/angular-bootstrap-lightbox, which trips everything up.

It'd be okay for me to just skip the provided functionality for IE8 users, but how would I actually do that?

I've tried to naively just replace the module with a no-op version from inside a conditional comment, but it doesn't seem to work:

<!--[if lt IE 9]>
<script type="text/javascript">var IE8 = true;</script>
angular.module('bootstrapLightbox', []);
<![endif]-->

Any suggestions?

Edit

Now it works. I also needed to define the 'this.$get'-function inside the Lightbox provider as a no-op:

<!--[if !IE]-->
<script src="bower_components/angular-bootstrap-lightbox/dist/angular-bootstrap-lightbox.js"></script>
<!--<![endif]-->

<!--[if gt IE 8]>
<script src="bower_components/angular-bootstrap-lightbox/dist/angular-bootstrap-lightbox.js"></script>
<![endif]-->

<!--[if IE 8]>
<script type="text/javascript">
    angular.module('bootstrapLightbox', []).provider('Lightbox', function () {
        this.$get = function noop() {
            return true;
        }
    });
</script>
<![endif]-->
도움이 되었습니까?

해결책

First, it doesn't look like your angular.module code is inside a script tag. Also, try conditionally including the module, or conditionally loading a different "app" module (one that does not require this dependency):

Conditional script include

<!--[if lt IE 9]><!-->
<script type="text/javascript">angular.module('bootstrapLightbox', []);</script>
<!--<![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> 
<script src="bower_components/angular-bootstrap-lightbox/dist/angular-bootstrap-lightbox.js"></script> 
<!--<![endif]-->

Conditional app module load

<!--[if lt IE 9]><!-->
<html ng-app="myLegacyIEAppModule">
<!--<![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> 
<html ng-app="myAppModuleForEveryoneElse"> 
<!--<![endif]-->
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top