Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Angular Basics Angular Components Nesting Components

Andrew Hickman
Andrew Hickman
1,686 Points

Error When Importing Entry Components

Hi Treehouse friends! I'm really stuck on a console error thrown when I try to import the EntryList component into app.module. The app attempts to import infinite instances of the component, and the console throws this error:

(unknown) EXCEPTION: Error in ./EntryListComponent class EntryListComponent - inline template:2:0 caused by: Maximum call stack size exceeded

Been trying to debug for over an hour, finally gave up and rewatched the video making sure to copy Andrew's code line-by-line, and still can't find the problem. Any help much appreciated!

App.module.ts:

import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {AppComponent} from './app.component';
import {EntryListComponent} from './entries';

@NgModule({
    imports: [BrowserModule],
    declarations: [AppComponent, EntryListComponent],
    bootstrap: [AppComponent]
})
export class AppModule{

}

Index.ts:

export * from './entry-list/entry-list.component';
export * from './entry/entry.component';

App.component.html:

<app-entry-list></app-entry-list>

Entry-list.component.ts:

import {Component} from '@angular/core';

@Component({
    selector: 'app-entry-list',
    templateUrl: 'entry-list.component.html',
    styleUrls: ['entry-list.component.css']
})

export class EntryListComponent {

}

Entry-list.component.html:

Hello From Entry List Component HTML
<app-entry-list></app-entry-list>

2 Answers

Andrew Hickman
Andrew Hickman
1,686 Points

Problem solved:

I had two <app-entry-list> tags, one in app.component.html, and one in entry-list.component.html. Obviously the referenced tag should only be in app.component.html, because that's the only component that the application bootstraps. Wow, what a headache for such an obvious mistake.

what may have been the problem was where you have

import {EntryListComponent} from './entries'; 

should be

import { EntryListComponent, EntryComponent } from './entries';