{"id":1811,"date":"2022-08-30T15:19:38","date_gmt":"2022-08-30T15:19:38","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/02\/how-do-you-get-angular-js-to-work-in-a-windows-8-store-app-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:19:38","modified_gmt":"2022-08-30T15:19:38","slug":"how-do-you-get-angular-js-to-work-in-a-windows-8-store-app-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/how-do-you-get-angular-js-to-work-in-a-windows-8-store-app-collection-of-common-programming-errors\/","title":{"rendered":"How do you get Angular.js to work in a Windows 8 store app?-Collection of common programming errors"},"content":{"rendered":"<p>The app runs but Angular data objects are not recognized.<\/p>\n<p>Here is the JavaScript error I am getting:<\/p>\n<pre><code>Exception was thrown at line 1059, column 11 in ms-appx:\/\/28934b41-4dd2-4414-b9a9-\na73c11c1b743\/js\/angular.js\n0x800a139e - JavaScript runtime error: No module: ngLocale\nException was thrown at line 4473, column 9 in ms-appx:\/\/28934b41-4dd2-4414-b9a9-\na73c11c1b743\/js\/angular.js\n0x800a139e - JavaScript runtime error: HierarchyRequestError\nThe program '[5112] WWAHost.exe' has exited with code 1 (0x1).\n<\/code><\/pre>\n<p>Here is the function around line 1059 in angular.js:<\/p>\n<pre><code>return ensure(modules, name, function() {\n    if (!requires) {\n      throw Error('No module: ' + name);\n    }\n<\/code><\/pre>\n<p>And here is the function around line 4473:<\/p>\n<pre><code> if (parent) {\n    parent.replaceChild(newNode, oldNode);\n  }\n<\/code><\/pre>\n<p>I was able to fix the first error that I came across:<\/p>\n<pre><code>Unhandled exception at line 2031\n JavaScript runtime error: Unable to add dynamic content\n<\/code><\/pre>\n<p>by wrapping all of angular.js with <code>MSApp.execUnsafeLocalFunction<\/code><\/p>\n<pre><code>  MSApp.execUnsafeLocalFunction(function () {\n          ....\n      });   \n<\/code><\/pre>\n<p>These errors are from a test app that I created following the todo list example from the Angular.js homepage.<\/p>\n<p>Now what? According to a free Microsoft Event I attended, &#8220;It is easy to add any third party JavaScript framework\/library to a Windows 8 app!&#8221; I may be new to this&#8230;but I don&#8217;t think this is very easy!<\/p>\n<p>Is it even possible to use Angular.js with a Windows 8 app?<\/p>\n<ol>\n<li>\n<p>The reason is because Angular puts html comment tags for ng-repeat and similar directives. Unfortunately Microsoft considers these to be unsafe when put in from Javascript using .innertHTML and is not allowed. This can be found here:<\/p>\n<p>http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/apps\/hh465388.aspx<\/p>\n<p>It happens at line 1534 in jQLite:<\/p>\n<pre><code>var div = document.createElement('div');\n            \/\/ Read about the NoScope elements here:\n            \/\/ http:\/\/msdn.microsoft.com\/en-us\/library\/ms533897(VS.85).aspx\n            div.innerHTML = ' ' + element; \/\/ IE insanity to make NoScope elements work!\n            div.removeChild(div.firstChild); \/\/ remove the superfluous div\n<\/code><\/pre>\n<p>What happens is the element is<\/p>\n<pre><code>\n<\/code><\/pre>\n<p>Then when angular does div.innerHTML = &#8230; the element gets removed. If you put a break point at div.removeChild, you will notice the div.innerHTML is without the element.<\/p>\n<p>[EDIT] After writing this response I tried adding<\/p>\n<pre><code>MSApp.execUnsafeLocalFunction(function () { div.innerHTML = ' ' + element });\n<\/code><\/pre>\n<p>It works! Apparently you have to wrap all of angularjs in MSApp.execUnsafeLocalFunction and then that line specifically.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-12-02 01:40:40. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>The app runs but Angular data objects are not recognized. Here is the JavaScript error I am getting: Exception was thrown at line 1059, column 11 in ms-appx:\/\/28934b41-4dd2-4414-b9a9- a73c11c1b743\/js\/angular.js 0x800a139e &#8211; JavaScript runtime error: No module: ngLocale Exception was thrown at line 4473, column 9 in ms-appx:\/\/28934b41-4dd2-4414-b9a9- a73c11c1b743\/js\/angular.js 0x800a139e &#8211; JavaScript runtime error: HierarchyRequestError The [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1811","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1811","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1811"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1811\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}