Angular: ERROR in RangeError: Maximum call stack size exceeded

I was messing around with my Angular website today and I hit a weird error:

ERROR in RangeError: Maximum call stack size exceeded

The error message wasn’t giving much away and a quick Google didn’t throw up anything useful.

I’d been fiddling around with page names. I was trying to get angular to render: http://darrylbrown.co.uk/testpage/index.html?language=EN. I could see Angular loading the page. It was parsing the URL and changing it to an HTML5 friendly version: http://darrylbrown.co.uk/testpage. That was the clue.

I didn’t have a default route set on /testpage. The solution was simple: add a catch-all route:

{ path: '**', component: TestPageComponent }

Here’s the full code snippet:

const routes: Routes = [
    { path: '', component: TestPageComponent },
    { path: '**', component: TestComponent }
];
 
@NgModule({
    imports: [
        RouterModule.forChild(routes),
    ],
    ...
})
export class TestPageModule {
}

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.