Angular - The Complete Guide 2020 Edition
Angular - The Complete Guide 2020 Edition
a
a
a
a
app.component.html
a
app.module.ts
a
a
REGISTER
LOGIN
HOME-PROFILE
USER-PROIFLE
SERVICES
MODELS
MODELS
user.model.ts
app-routing.module.ts
app.component.html
register.component.html
app.module.ts
register.component.ts
register.component.html
register.component.ts
app.module.ts
auth.service.ts
app.modulet.s
register.component.ts
login.component.html
app.module.ts
login.component.ts
register.component.html
login.component.ts
app.module.ts
auth.service.ts
login.component.ts
home-profile.service.ts
app.module.ts
home-profile.service.ts
home-profile.component
app.module.ts
user-profile.service.ts
user-profile.component.
home-profile.component
user-profile.component.
user.controller.js
user.controller.js
register.component.ts
login.component.ts
register.component.ts
login.component.ts
auth.guard.ts
auth.service.ts
auth.guard.ts
app.module.ts
app-routing.module.ts
token-interceptor.service
app.module.ts
auth.service.ts
token-interceptor.service
user.routes.js
user.routes.js
special-events.componen
app.component.ts
app.component.html
auth.service.ts
auth.service.ts
SUGGESTIONS
Encrypt Passport
Do not return the password
Improve Registration
if email already exitst
Add erro handling
Create a new event
Where user can can create new event
Fetch events from the database instead of being hardcoded
Events created by a specific user
USING COMPONENTS
In app.component.html let's add <app-recipes></app-recipes> and <app-shopping-list></app-shopping-list> Component
In recipes.component.html lets add <app-recipe-list></app-recipe-list> and <app-recipe-detail></app-recipe-detail>
In recipe-list.component.html, let add <app-recipe-item></app-recipe-item> component
In shopping-list-component.html, lets add <app-shopping-edit></app-shopping-edit> Component
HEADER COMPONENT
In header.component.html - Lets work on the navigation bar
RECIPE-LIST COMPONENT
Let's add array of recipes = []; in recipe-list.component.ts
CREATING RECIPE MODEL
Let's create recipe model in recipes Folder path ng g class recipe --type=model
Let's create the Blueprint of our recipe model. This is how our recipe should look like.
Remarks
model is a blueprint of an object we create. No need decorator.
constructor () is built in function that every class has. It is being initiated once we created a new instance of our class.
in this example it's our Recipe class in recipe.model.ts
recipe-list COMPONENT
in recipe-list.component.ts - Base on the blueprint we created, let create a new Recipe object in an array.
in recipe-list.component.html - this how will look like our RecipeList in the Browser
in recipe.list.component.html - let's add String Interpolation and Property Binding
Let's duplicate Recipe Object in recipe-list.component.ts
Remarks
This is where we are displaying the list of Recipe Name, Desc, and Image
RecipeDetail COMPONENT - HTML
In recipe-detail.component.html
ShoppingList COMPONENT HTML
In shopping-list.component.html
ShoppingList COMPONENT - TYPESCRIPT
In shopping-list.component.ts - simply added ingredients[]
CREATING INGREDIENT MODEL
Let's create ingredients model in app Folder path ng g class ingredient --type=model
In ingredient.model.ts - Blueprint of our ingredient Model
ShoppingList COMPONENT - TYPESCRIPT
in shopping-list.component.ts - Creating the Shopping List
in shopping-list.component.html - Let's output the Shopping List
ShoppingEdit COMPONENT - HTML
in shopping-edit.component.hmtl - UI for our ShoppingEdit C
Components and Data Binding
Adding navigation with Event Binding and ngIf
Passing Recipe Data with Property Binding
Passing Data with Event and Property Binding (Combined)
Allowing the User to Add Ingredients to the Shopping List
Directive
Building and Using a Dropdown Directive
Services & Dependency Injection
Setttingup Services
Managing Recipes in a Recipe Service
Using
Adding a Service for Cross-Component
the Shopping List Service Communication
Using Services for Pushing Data from A to B
Adding Ingredients to Recipes
0
in model Folder, go to user.model.ts. Let's create the Blue Print of our user
ng generate component register
ng generate component login
ng generate component HomeProfile
ng generate component UserProfile
ng g s services/user
ng g class models/user --type=model
CREATE the BLUEPRINT of our USER
MODELS Folder
in model Folder, go to user.model.ts. Let's create the Blue Print of our user
ADDING ROUTES
Adding routes for all of our component
Implementing logout:
Implementing logout: used ngIf on the register and login button, and add logout button
Implementing logout: let's define the logoutUser() method in auth.service.ts
Implementing logout: Update our logoutUser() method
n the password
can can create new event
from the database instead of being hardcoded
ed by a specific user
thoerization
INFO INFO
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
INFO INFO
STEPS STEPS
STEPS STEPS
INFO INFO
STEPS STEPS
STEPS STEPS
INFO INFO
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
ipTests true STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
sTEPS sTEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
INFO INFO
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
STEPS STEPS
FLOW
BASIC
PreRequisite: Node Js and NPM
FRONTEND - ANGULAR
How create, Angular Project. In case you already created Main FOLDER and backend Project.
Install Angular
to change the Port and use watch - instead ng serve use npm start on Terminal
Let's install bootstrap, npm install bootstrap@3 --save - Version 3 Used for this Tutorial
In angular.json in styles array add the boostrap path
Just to check if Bootsrap is working add this on app.component.html
In Command Prompt>cd to Main Project Folder>then code .
Standard Setup - Angular : After Successful Installation
Add FormsModule Typescript Form Feature in app.moude.ts to use 2 Way Data Binding in Angular
Delete all code in app.component.html - let’s stat fresh…
ng generate - SCHEMATIC COMMANDS
a
CREATING COMPONENTS
Create Header Component ng generate component header --skipTests true
Use the HeaderComponent in app.component.html
Create RecipesComponent inside the App Folder ng generate component recipes --skipTests true
Create RecipeListComponent inside recipes Folder ng g c recipes/recipe-list --skipTests true
Create RecipeDetailComponent inside recipes Folder ng g c recipes/recipe-detail --skipTests true
Create RecipeItemComponent inside recipe-list Component ng g c recipes/recipe-list/recipe-item --skipTests true
Create a ShoppingListComponent in the App Folder ng g c shopping-list --skipTests true
Create ShoppingEditComponent inside the ShoppingListComponent ng g c shopping-list/shopping-edit --skipTests true
USING COMPONENTS
In app.component.html let's add <app-recipes></app-recipes> and <app-shopping-list></app-shopping-list> Component
In recipes.component.html lets add <app-recipe-list></app-recipe-list> and <app-recipe-detail></app-recipe-detail>
In recipe-list.component.html, let add <app-recipe-item></app-recipe-item> component
In shopping-list-component.html, lets add <app-shopping-edit></app-shopping-edit> Component
HEADER COMPONENT
In header.component.html - Lets work on the navigation bar
RECIPE-LIST COMPONENT
Let's add array of recipes = []; in recipe-list.component.ts
CREATING RECIPE MODEL
Let's create recipe model in recipes Folder path ng g class recipe --type=model
Let's create the Blueprint of our recipe model. This is how our recipe should look like.
Remarks
model is a blueprint of an object we create. No need decorator.
constructor () is built in function that every class has. It is being initiated once we created a new instance of our class.
in this example it's our Recipe class in recipe.model.ts
recipe-list COMPONENT
in recipe-list.component.ts - Base on the blueprint we created a new Recipe object in an array.
in recipe-list.component.html - this how will look like our RecipeList in the Browser
in recipe.list.component.html - let's add String Interpolation and Property Binding
Let's duplicate Recipe Object in recipe-list.component.ts
Remarks
This is where we are displaying the list of Recipe Name, Desc, and Image
RecipeDetail COMPONENT
In recipe-detail.component.html
ShoppingList COMPONENT HTML
In shopping-list.component.html
ShoppingList COMPONENT
In shopping-list.component.ts - simply added ingredients[]
CREATING INGREDIENT MODEL
Let's create ingredients model in app Folder path ng g class ingredient --type=model
In ingredient.model.ts - Blueprint of our ingredient Model
ShoppingList COMPONENT - TYPESCRIPT
in shopping-list.component.ts
in shopping-list.component.html - Let's output the Shopping List
ShoppingEdit COMPONENT - HTML
in shopping-edit.component.hmtl - UI for our ShoppingEdit C
Components and Data Binding
Adding navigation with Event Binding and ngIf
Passing Recipe Data with Property Binding
Passing Data with Event and Property Binding (Combined)
Allowing the User to Add Ingredients to the Shopping List
Directive
Building and Using a Dropdown Directive
Services & Dependency Injection
Setttingup Services
Managing Recipes in a Recipe Service
Using
Adding a Service for Cross-Component
the Shopping List Service Communication
Using Services for Pushing Data from A to B
Adding Ingredients to Recipes
ADDING ROUTES
Adding routes for all of our component in app-routing.module.ts
pTests true
--skipTests true
ping-list> Component
p-recipe-detail>
tance of our class.
POST localhost:3000/api/authenticate
GET localhost:3000/api/homeprofile
GET localhost:3000/api/userprofile
Getting an Error from Here…unable to register login and view members path
y app.component.html
App Component
<app-header></app-header>
<app-recipes></app-recipes>
<app-recipe-list></app-recipe-list>
<app-recipe-item></app-recipe-item>
<app-recipe-detail></app-recipe-detail>
<app-shopping-list></app-shopping-list> Component
<app-shopping-edit></app-shopping-edit>
RECIPES COMPONENT
SHOPPINGLIST COMPONENT
Passing Recipe Data with Property Binding
Remarks
Below recipe-list will be remove from recipe-list.componenet.html, and we are going to move it in recipe-item.component.html
SETUP STEP
PreRequisite: Node Js and NPM INFO
Angular first time installation. SETUP
How create, Angular Project. In case you already created Main FOLDER and backend Project. SETUP
To change the Port and use watch - instead ng serve use npm start on Terminal SETUP
Let's install bootstrap, npm install bootstrap@3 --save - Version 3 Used for this Tutorial SETUP
In angular.json in styles array add the boostrap path SETUP
Open your angular project using Visual Studio Code SETUP
Standard Setup - Angular : After Successful Installation INFO
Add FormsModule Typescript Form Feature in app.moude.ts to use 2 Way Data Binding in Angular SETUP
Delete all code in app.component.html - let’s stat fresh… INFO
ng generate - SCHEMATIC COMMANDS INFO
CREATING COMPONENTS
Create header Component SETUP
USING COMPONENTS
Use header Component in app.component.html SETUP
If header Component has been done manually. You have to register it manually in app.module.ts INFO
Use recipes Component and shopping-list Component in app.component.html SETUP
Use recipe-list and recipe-detail Component in recipes.component.html SETUP
Use recipe-item Component in recipe-list.component.html SETUP
Use shopping-edit Component in shopping-list-component.html SETUP
Remarks
App Component is our root Component
We have 3 parent Components here and it has child components
HEADER COMPONENT NAVIGATION BAR
Adding Navigation Bar in our header Component STEP
SETUP
SETUP
SETUP
SETUP
SETUP
SETUP
SETUP
SETUP app.component.html
INFO app.module.ts
SETUP app.component.html
SETUP recipes.component.html
SETUP recipe-list.component.html
SETUP shopping-list.component.html
STEP header.component.html
STEP recipe.model.ts
STEP recipe.model.ts
STEP recipe-list.component.ts
STEP recipe-list.component.html
STEP recipe-list.component.html
STEPS recipe-detail.component.html
STEPS
STEP ingredient.model.ts
STEPS shopping-list.component.ts
STEP shopping-list.component.html
STEP shopping-edit.component.html