- Start by installing angular-cli:
npm i -g @angular/cli
- Generate a project using:
ng new angular-demo --style=scss
- Change into dir:
cd angular-demo
- Install project deps:
npm i
- Added box-sizing reset to
src/style.scss
- Delete contents of
src/app/app.component.html
- Create home component using
ng generate component home
- Go over all the files generated, and the changes to the
app.module.ts
file - Add home component to
app.component.html
usingapp-home
- Create a
pages
dir underapp
and move the home component topages
- The page should be broken now (may need to restart
ng serve
to make this happen) - Explain the changes that need to be made to
app.module.ts
- Add some data to the
home.component.ts
file and display that data inhome.component.html
- Create an about and contact page without using the cli generator
- Explain how to create files and what was being generated for you
- After creating the contact page, explain two-way data, attr, and event binding
- Ensure that the FormsModule is included in the
app.modules.ts
file. - Add RouterModule to the
app.module.ts
file - Add
<router-outlet></router-outlet>
to theapp.component.html
file. - Define routes for the three pages and a catch all route
- Create a components dir
- In the components dir, create a header component to house page nagviation.
- Add
<app-header />
toapp.component.html
.
- Clean up the html for the contact page
- Add CSS to make the contact page pretty
- Add validation functions to the contact ts file
- Bind the validation functions to the html file for ContactComponent.
- Rename about to communication, update the component, router, and header component
- Create a parent component
- Update the app.modules.ts file with the new component
- Create a child component
- Update the app.modules.ts file with the new component
- Add the child component to the parent component and explain the communication between the two
- Add the parent component to the communication component's html
- Create a service folder under src/app named 'services'
- Create a backend.service.ts file
- Add the backend service to
app.module.ts
- Add in a contact method for the contact page to use\
- Bring in the backend server into
contact.component.ts
file - Use the contact method in the submit of the contact page
- Add the HttpClient Module to the
app.module.ts
file.
- Create a session service to hold the current user information
- Add the service to
app.module.ts
- Create a auth service to handle login/logout/register
- Add the service to
app.module.ts
- Create a login page that uses the auth service
- Update the router to handle the 'login' route
- Update the header component to show a login/logout button
- Remind everyone that this is using object reference to keep track of logged in state
- Update the session service to use a Behavior subject to emit out the loggedIn status
- Update the
header.component.ts
file to leverage the observable - Update the header component's html file to make sure of the new methods and observable
- Inform the students that there are two different ways to use the observable in this code
- Added text file with links to more topics to study
- TypeScript
- Reactive Forms and Validations
- Debouncing inputs with Observables
This project was generated with Angular CLI version 6.0.0.
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Run ng generate component component-name
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module
.
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the --prod
flag for a production build.
Run ng test
to execute the unit tests via Karma.
To get more help on the Angular CLI use ng help
or go check out the Angular CLI README.