简体   繁体   中英

Create a windows universal app using angularjs

How to create a windows universal app with angularjs?

I created an universal windows app using visual studio, added the angular script (for testing purposes, I tried it on different ways with bower, manually and with nuget) and always get "Unable to add dynamic content".

Searching for this I found a lot of links trying to explain how to get around this error, for example: http://blog.kadople.com/2013/06/getting-started-with-angularjs-in.html . But it all seems to be very ugly or not working at all - at least not for windows universal apps. The demo app of the link mentioned is working but that involved hacking around in jquery code adding execUnsafeLocalFunction and that is something I really don't want to do. And I think this should be working with jquery version >= 2.0 - but ok, it is not.

How can we make this app "universal"? ;)

A great solution to this problem is to WinStore-JsCompat in your project. Just include it and add a reference in you .html file before all other scripts and you're good to go.

Windows Universal app development can be tricky, especially if you are using angularjs. As suggested by Sorskoot , winstore-jscompat is required to be able to use angularjs in your universal windows app.

I suggest using this fork of jscompat by AndyB that I found to be working with my test project.

Try adding ng-csp attribute to your Angularjs app as mentioned in their docs for windows universal apps https://docs.angularjs.org/api/ng/directive/ngCsp

You are now two steps closer to making a "universal" windows app!

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