{"id":2103,"date":"2022-08-30T15:22:04","date_gmt":"2022-08-30T15:22:04","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/26\/express-loads-controller-infinit-times-and-browser-windows-crashes-when-i-use-subpath-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:22:04","modified_gmt":"2022-08-30T15:22:04","slug":"express-loads-controller-infinit-times-and-browser-windows-crashes-when-i-use-subpath-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/express-loads-controller-infinit-times-and-browser-windows-crashes-when-i-use-subpath-collection-of-common-programming-errors\/","title":{"rendered":"Express loads controller infinit times and browser windows crashes when I use subpath-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m currently working with angularJS and I try to build a homepage. My routeconfig looks like this:<\/p>\n<pre><code>var app = angular.module('mml-annie', ['mmlServices']);\n\napp.config(['$locationProvider', function($location) {\n  $location.html5Mode(true); \/\/now there won't be a hashbang within URLs for browers that     support HTML5 history\n}]);\n\napp.config(['$routeProvider', function($routeProvider) {\n$routeProvider.\nwhen('\/team', {\n    templateUrl: 'partials\/team', \n    controller: TeamCtrl\n}).\n\notherwise({\n        redirectTo: '\/home'\n    });\n}]);\n<\/code><\/pre>\n<p>For testing purposes my controler looks like this:<\/p>\n<pre><code>function TeamCtrl($scope, Team) {\n\nconsole.log(\"TEST\");\n}\n<\/code><\/pre>\n<p>Everything I working fine except when my path get additions \/ fields. When I change <code>\"\/team\"<\/code> to <code>\"\/team\/team\/test\"<\/code> my app calls the controller until the app crashes. Not using html5 mode fixes the problem. But I would rather use the nice HTML5 mode without the hashbang.<\/p>\n<p>The app runs on <code>node.js<\/code> with express which serves the angular app for all requests except API calls.<\/p>\n<p>Do you have any idea what is happening? I have no clue&#8230;<br \/>\nOf course I can provide further information if needed.<\/p>\n<ol>\n<li>\n<p>the solution is as follows:<\/p>\n<p>My partials didn&#8217;t have the relative path prefix <code>\"\/\"<\/code>. So whenever i tried to advance in a path the server looked for a partials that wasn&#8217;t there, for example: \/team\/partials\/team<\/p>\n<p>Node then sent the basic layout which had itself the ng-view div again and started all over.<\/p>\n<p>Why do I always fiddle around for like 2 hours &#8211; then decide to write a question and 2 minutes later I find the answer&#8230;.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-12-26 03:15:21. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m currently working with angularJS and I try to build a homepage. My routeconfig looks like this: var app = angular.module(&#8216;mml-annie&#8217;, [&#8216;mmlServices&#8217;]); app.config([&#8216;$locationProvider&#8217;, function($location) { $location.html5Mode(true); \/\/now there won&#8217;t be a hashbang within URLs for browers that support HTML5 history }]); app.config([&#8216;$routeProvider&#8217;, function($routeProvider) { $routeProvider. when(&#8216;\/team&#8217;, { templateUrl: &#8216;partials\/team&#8217;, controller: TeamCtrl }). otherwise({ redirectTo: &#8216;\/home&#8217; [&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-2103","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2103","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=2103"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2103\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}