I'm trying to use the routeParams
so I can get part of a URL, but it gets me into an infinite loop when I try to access to the URL with a GET parameter. Currently, I have the following defined:
var nappet = angular.module('nappet', ['ngRoute', 'ngCookies']);
nappet.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$routeProvider
.when('/', {templateUrl: 'app/home/view/homeView.html', controller: 'homeController'})
.when('/organizadores', {templateUrl: 'app/organizers/view/organizerView.html', controller: 'organizerController'})
.when('/organizadores/:organizer', {templateUrl: 'app/organizers/view/organizerDetailView.html', controller: 'organizerController'})
$locationProvider.html5Mode(true);
}]);
And here's the controller:
nappet.controller('organizerController', function($scope, $location, $cookies, $http, $routeParams) {
if($routeParams.organizer === undefined) {
console.log('Works');
} else {
console.log('Infinite loop');
}
});
So, if I put anything replacing the organizer param, it prints that "Infinite loop" message in a loop, but it works when I don't use any parameter on the URL. What could be the problem here?