Build Your First Web App: Learn to Build Web Applications from Scratch by Deborah Levinson & Todd Belton

Build Your First Web App: Learn to Build Web Applications from Scratch by Deborah Levinson & Todd Belton

Author:Deborah Levinson & Todd Belton
Language: eng
Format: epub, azw3


The root component will also use the router, but in a different way. Open app.component.ts and change the template so it reads like this:

Don’t change anything in the rest of the file, just the template.

We’ve added a little temporary formatting to get the header to display on a background of our banner color. That’s not obligatory.21 The important part is the <router-outlet> tag pair. In place of these, the component currently selected by the router will be displayed. When the app first starts, the path will be empty (just localhost:3000/), so the MealEntryComponent template will be shown, as we have told it to do in the routes table. Later, if we navigate to a different component (using the navigation functions we’ve created), the contents of this tag pair will change accordingly.

In other words, we’ve just set up the root component as a “frame” that will display all our other components, depending on navigation. The only HTML in the root component that doesn’t change with navigation is the title banner.

We don’t need to import or declare use of Router in our root component because we’re not using Router data or functions anywhere within the component’s code. We get <router -outlet> “for free”—assuming we remember to add the appropriate declarations to the root module, which we get to shortly.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.