Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Phone App in JavaScript with AngularJS

I am developing a Windows Phone Application in JavaScript. I am using the AngularJS library. The problem is that I cannot add a dynamic content because of security reasons.

The error I get: HTML1701: Unable to add dynamic content '<div id="view_login" class="view"> <div id="view_login_container"> <img class="logo" src="http://oi60.tinypic.com/okwifa.jpg"> <input type="text" placeholder="Username" ng-model="loginUsername"> <input type="password" placeholder="******" ng-model="loginPassword"> <button ng-click="doLogin()">Login</button> <button ng-click="changeView('/signup')" class="link">... or sign up now</button> </div> </div>'. A script attempted to inject dynamic content, or elements previously modified dynamically, that might be unsafe. For example, using the innerHTML property to add script or malformed HTML will generate this exception. Use the toStaticHTML method to filter dynamic content, or explicitly create elements and attributes with a method such as createElement. For more information, see http://go.microsoft.com/fwlink/?LinkID=247104.

I changed one line in AngularJS library which should fix the problem:

append:function(a,c){
   **MSApp.execUnsafeLocalFunction(function () {**
      r(new N(c),function(c){
         1!==a.nodeType&&11!==a.nodeType||a.appendChild(c)
      })
   });
} 

Unfortunately it did not work.

I spent several hours trying to find a solution, but I did not manage it. I would appreciate any suggestions how to make working the Windows Phone App written in JavaScript with AngularJS.

like image 424
Adam Avatar asked Sep 11 '26 12:09

Adam


1 Answers

Microsoft Open Technologies recently released a shim which will prevent this exact problem for Windows Store apps using AngularJS, as well as many other popular JavaScript libraries.

Simply download the JavaScript Dynamic Content shim off of GitHub, then reference the file towards the beginning of your app before any other scripts are run. You should no longer see a dynamic content error.

Let me know if this solves your problem!

like image 108
jayrenn Avatar answered Sep 13 '26 00:09

jayrenn