简体   繁体   English

Windows Metro应用程序和Angular路由ui和动态内容

[英]Windows Metro app and Angular route ui and dynamic content

I have an existing angular / phonegap app that I'm trying to port to a windows metro app for win8. 我有一个现有的angular / phonegap应用程序,试图将其移植到win8的Windows Metro应用程序。 I've replaced my jQuery with a metro specific version and I've wrapped each angular module in the MSAp.execUnsafeLocalFunction method and I'm getting the application to sort of compile. 我已经用Metro特定版本替换了jQuery,并将每个angular模块包装在MSAp.execUnsafeLocalFunction方法中,并且使应用程序可以进行编译。

What is happening is that the page is built using angular ui router , so I'm able to see the dynamically created page, with angular ui router combining the 3 or 4 partials based on the route. 发生的事情是该页面是使用angular ui路由器构建的,因此我能够看到动态创建的页面,其中angular ui路由器基于该路线结合了3或4个部分。 However, when Angular starts to go through ng-bind, ng-repeat, etc... I'm getting the following error, "JavaScript runtime error: Unable to add dynamic content. A script attempted to inject dynamic content, or elements previously modified dynamically, the might be unsafe..." 但是,当Angular开始执行ng-bind,ng-repeat等...时,出现以下错误,“ JavaScript运行时错误:无法添加动态内容。脚本试图注入动态内容或以前的元素动态修改,可能不安全...”

I've looked to see how others have overcome this issue, but I have not found anything that works. 我一直在寻找其他人如何克服这个问题的方法,但是我没有发现任何可行的方法。 I'm worried that what I'm doing is going to have force me to rewrite the application using the WinJS library. 我担心自己的工作会迫使我使用WinJS库重写应用程序。

Does anyone have any resources or experience that can help me with this? 有没有人有任何资源或经验可以帮助我呢?

What works for me is adding the ng-csp directive to the HTML tag. 对我ng-csp是将ng-csp指令添加到HTML标记中。 This disables some of the dynamic content stuff of Angular. 这将禁用Angular的某些动态内容。 I didn't even wrap anything in exeUnsafeLocaFunction. 我什至没有在exeUnsafeLocaFunction中包装任何东西。 I'm not sure if it will work on Angular UI Router though... 我不确定它是否可以在Angular UI Router上运行...

More on the ng-csp directive here ... 更多有关ng-csp指令的信息 ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM