16

I have small trouble with angularjs and internet explorer9. It look like, that angularjs is not loading correctly. If I starting ie with my application, nothing will work, but if I start the development tools of ie9 and refresh the page, my application will work and everything is loading and ready to use.

I have no idea, what happen and how to solve this issue. I using angularJs Version 1.1.5. Big thanks!

Update & Resolved

My problem was, that I had everywhere console.log (..). On FF or Chrome, everything works, but with II9, something happens, that ie stop after the statement console.log(...); After removing console.log(..) from my JavaScript, my application also works on IE7/8/9.

But ??

But I would ask why IE has so much problems with console.log?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
moohkooh
  • 917
  • 1
  • 10
  • 25
  • Do you necessarily have to open the developer tools or a simple refresh also works? – callmekatootie Jun 10 '13 at 15:41
  • Only refresh doesnt work, only if the dev Tools is Open – moohkooh Jun 10 '13 at 22:01
  • Had the same issue with IE8. Baezy's answer was correct (and should be marked as such). I took out two console.log() lines from my app and it worked. – Michael Oryl May 19 '14 at 14:58
  • console.log() on IE8 and IE9 is enabled only after opening dev tools for a tab: http://stackoverflow.com/a/5473193/3211434. As @Pavel mentions below, always use $log. – dwong May 05 '15 at 14:21

3 Answers3

15

I run in to the same issue and what fixed it was creating window console in the parent controller before using it. You can add the following code and try.

window.console = window.console || {};
window.console.log = window.console.log || function() {};
Jens Erat
  • 37,523
  • 16
  • 80
  • 96
idealistic
  • 191
  • 2
  • 6
  • 1
    I cannot tell you how much time you probably just saved me with this. Thanks! – Michael Oryl May 19 '14 at 14:55
  • After hours of trying to figure out what was wrong with out intranet app I found this. If only I had found you sooner. I have a debuggingmode flag set as a global variable and only expose console.log when this is true. – Mike Rouse Nov 20 '14 at 17:15
4

Use $log service. It will be injected in your controllers. https://docs.angularjs.org/api/ng/service/$log

Pavel Nikolov
  • 9,401
  • 5
  • 43
  • 55
  • Just a comment, using $log.log("...") will also have same problem, using $log.info(...) can work in IE. – Mavlarn Apr 03 '14 at 09:45
3

Are you making a call to console.log in your code? If yes, this will not be available in IE unless you open the dev tools.

Christian
  • 1,258
  • 10
  • 11
  • ok my mistake. Of course that all logs will be visible in dev tools of ie. In my case, my page will not loaded correctly (angularjs stops), binding i broken, my list will not fill up ( ng-repeat) etc. If i open the dev tools of ie and reloading the page, everythink works – moohkooh Jun 10 '13 at 14:02
  • Thanks for posting this question. I had the same issue. IE Idiosyncrasies I guess. – lostpacket Aug 05 '13 at 14:47