Angular April
Components and Routing
Goals
- Create components for our primary navigation (pages)
- Set up routing for those pages
- Display page components only for the corresponding route
Notes:
Creating components:
- mkdir src/app/components
- cd src/app/copmonents
- (make sure you are in the components directory before running this command) ng g component my-component
Setting up routing in the app.module.ts file:
- import the router by adding: import { RouterModule } from '@angular/router';
- at the end of the "imports" list add: RouterModule.forRoot([])
- for each route, add a path (inside the forRoot array...): { path: 'my-component', component: MyComponent }
Setting up routing on your pages: (app.component.html)
- place "<router-outlet></router-outlet>" where you want your components displayed on the page (typically the bottom under any navigation...)
- add navigation links by replacing "href" with "routerLink": <a routerLink="/about-me">About Me</a>
Resources
More Help
Suggested routing for all 4 projects:
Project 1:
Personal Website
- about-me
- my-portfolio
- contact-me
- todo-list
- my-contacts
- my-calendar
Project 2:
Business Website
- about
- products
- services
- schedule
- clients
- client-detail
Project 3:
Online Store
- products
- product-detail
- cart
- order
- customers
- customer-detail
Project 4:
Community Website
- timeline
- friends
- followers
- profile
- announcements
- forum
- post
Share your project, ask questions, or help someone else on the Angular April - Facebook group page.
If you have a comment or suggestion for "Angular April" then send and email to: KarenFreemanSmith@gmail.com with the subject line: "Angular April".