Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Phone 7 and 8 with PhoneGap + Angular dies during bootstrapping

  • Windows Phone 7 or 8
  • PhoneGap 3
  • AngularJS 1.2

I have a PhoneGap app using AngularJS that works great on iOS and Android, but I'm having a problem getting it to work on Windows Phone 7 and 8.

The app starts fine and I see my index.html page (which in my case is just a loading screen). Source files are loaded and my pre-boot code is running fine.

Then it stops and nothing happens.

I've littered "console.log" messages throughout the code and I see it gets to the point of angular.bootstrap() and then dies. I'm not familiar enough with angular to know what to do next or how to debug this further to track down what the absolute problem code might be. Inside of bootstrap() begins the maze of DI calls so the code becomes much less linear.

I do see this error in the console but have no idea what it means or how to fix it:

An exception of type 'System.NotSupportedException' occurred in Microsoft.Phone.ni.dll and wasn't handled before a managed/native boundary

No other errors or any output is logged to the console. I tried delaying all of my bootstrap code by 10 seconds with a setTimeout and that error is always reported before angular.bootstrap() is called, so I don't know if it is even related.

Also worth noting that I've tried the app in IE on the desktop and it works fine there.

So my question is: How do I go about debugging this?

like image 729
chroder Avatar asked Aug 29 '13 17:08

chroder


2 Answers

I am unsure of WP7/8 but if it follows Windows 8 pattern try adding JQuery 2.0 before angular.js

http://net.tutsplus.com/tutorials/javascript-ajax/building-windows-store-applications-with-jquery-2-0/

like image 126
Jason Als Avatar answered Sep 30 '22 23:09

Jason Als


I agree with Jason, use Windows special/custom jQuery. And add unsafe=true

<script src="js/jquery-1.8.2-win8-1.0.min.js"></script>
<script type="text/javascript">
jQuery.isUnsafe = true;
</script>

The functionality of the Windows 8-patch had been included in jQuery 2.0. So can just use jQuery 2.0 in the same way, and it will work'.

So you can also use:

<script src="/lib/jquery-2.0.0.min.js"></script>
<script>
jQuery.isUnsafe = true;
</script>
like image 37
MarmiK Avatar answered Oct 01 '22 00:10

MarmiK