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 Setting Up an Angular Application Your First Angular Application

The sequence of loading components

Hi all,

I have a question regarding what we see in the app. So, we have a component that is called AppComonent, and we already have some HTML code inside the app-root tag.

Now my question is how come "Loading does appear before the component's code? I was expecting the HTML component to appear directly. Is it being loaded from the tag of app-root? That is why the message inside that tag appears first? or how does it work?

Thank you!

Best Regards, Chada

3 Answers

akak
akak
29,445 Points

The HTML page is loaded before Angular application. That's why, for a moment, you see Loading. The browser just renders the content of app-root tag. Browsers really don't care if it's a known tag for them or not. So they render the only content that is on the page which is Loading text. After a moment Angular app takes over and replaces the content of this tag. That's why Loading disappears and the app is visible.

Here is a stack overflow that will address why you see that loading and when the js is injected you see your app. https://stackoverflow.com/questions/27175347/what-is-the-order-of-html-assets-when-page-load

Hope this helps. =) happy coding