Angular 4 application prevent directive from loading if IE browser

问题内容:

I am using angular 4 application and would like the main application directive to be rendered only it is not a IE browser.

If it is a IE Browser I would like to display a message stating that this application is not available for IE (all version of IE from 6 to 11).

IE comments are no longer supported in IE 10 onwards, so not sure how to do the above for all IE browsers

Thanks

问题评论:

    
so you’ve tried what?

答案:

答案1:

You use us-parser-js (at npm or github) to find what browser is currently being using. Once you know that you can have your directive do different thing.

Better approach would be to have two directives, one your application main directive and two, message directive. You can then determine type of browser before app loads and then set them on and off with ngIf depending upon current browser name.

Hope this helps!

答案评论:

答案2:

Internet Explorer doesn’t support the navigator object.

What you could simply do is

if (!navigator) { /* do your stuff */ }

I remember using it for the HTML 5 File API, works pretty well !

答案评论:

原文地址:

https://stackoverflow.com/questions/47755998/angular-4-application-prevent-directive-from-loading-if-ie-browser

添加评论