Express loads controller infinit times and browser windows crashes when I use subpath-Collection of common programming errors
I’m currently working with angularJS and I try to build a homepage. My routeconfig looks like this:
var app = angular.module('mml-annie', ['mmlServices']);
app.config(['$locationProvider', function($location) {
$location.html5Mode(true); //now there won't be a hashbang within URLs for browers that support HTML5 history
}]);
app.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/team', {
templateUrl: 'partials/team',
controller: TeamCtrl
}).
otherwise({
redirectTo: '/home'
});
}]);
For testing purposes my controler looks like this:
function TeamCtrl($scope, Team) {
console.log("TEST");
}
Everything I working fine except when my path get additions / fields. When I change "/team"
to "/team/team/test"
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.
The app runs on node.js
with express which serves the angular app for all requests except API calls.
Do you have any idea what is happening? I have no clue…
Of course I can provide further information if needed.
-
the solution is as follows:
My partials didn’t have the relative path prefix
"/"
. So whenever i tried to advance in a path the server looked for a partials that wasn’t there, for example: /team/partials/teamNode then sent the basic layout which had itself the ng-view div again and started all over.
Why do I always fiddle around for like 2 hours – then decide to write a question and 2 minutes later I find the answer….