3

I'm currently trying to build a simple routing Angular application with a Node/Express backend. Whenever I start up the server however, the page dies. Whenever I am able to get an error, it says "RangeError: Maximum call stack size exceeded".

I'm a bit confused as I know Im not doing anything intensive... What am I missing?

http://plnkr.co/edit/BzkcruqxDAKx5Kp3E26G

app.js

angular.module('NewsEye', ['newsEyeRoutes']) 

.controller('mainController', function() {

    //bind this to view-model   
    var vm = this;

    vm.message = 'hey there! something is over here...';

})

.controller('homeController', function() {
    var vm = this;

    vm.message = 'Home page test.'
})

.controller('contactController', function() {
    var vm = this;

    vm.message = 'Contact test.'
})

app.routes.js

angular.module('newsEyeRoutes', ['ngRoute'])

.config(function($routeProvider, $locationProvider) {
    $routeProvider

    .when('/', {
        templateUrl : 'views/home.html',
        controller  : 'homeController',
        controllerAs: 'home'
    })

    .when('/contact', {
        templateUrl : 'views/contact.html',
        controller  : 'contactController',
        controllerAs: 'contact'
    })

$locationProvider.html5Mode(true);
})

server.js, index.html, and a partial view can be found in the plunkr link.

1 Answer 1

0

in your routeprovider you are not giving an otherwise clause - which sets the default route.

Try adding one ...

.otherwise('/');

what url are you visiting when you get this error?

do you get it on all urls?

Sign up to request clarification or add additional context in comments.

3 Comments

I appear to get it on all urls. When the page loads, it won't stop, and eventually is killed by my browser. I tried adding the "otherwise" case, but it still gets caught up on something...
mm difficult to say BUT another guesstimate ... $locationProvider.html5Mode(true); is used ... are you setting <base href='/' /> in your HTML? ... have you added ng-app="newsEyeRoutes" in your HTML ?
another thought ... could you explain what is happening in the NET tab in your browsers dev tool ... is it making repeated requests for the same page? or is it just making one single request and then dying?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.