Angular Notes
Angular Notes
NOTE CORRECT: IN COMMAND PROMPT FIRST INSTALL NPM THEN NAVIGATE INTO FOLDER USING
CD COMMAND ,THEN CREATE NEW PROJECT USING NG NEW PROJECTNAME.
then navigate intoyour project name using cd command , then ng serve and run local
host .
note: next day when u start work after closing everything, open visual code,goto
its terminal ,install npm then go to ur folder uding cd command,
then go to ur project name using cd command.
NOTE: if in terminal its give the error: "this command can be run in only abn cli
project", then using cd command navigate
intour project name.
note: try to keep ur folder name and project name seperate.
2. whatever u do in any component just save it.
HOW TO CREATE NEW COMPONENTS:
1.MANUALLY
2.CLI COMMAND IN TERMINAL
NOTE:
2.USING CLI
a. Type ng g c componentname, it will be created.
b. delete the soec file for time being.
c. since this component was created by using cli therefore we dont need to do
anything in .ts file as we did while craeting the component manually.
d.whatever u want to dispaly in the component created write that in .html file.
NOTE: remember to save whatever u do instantly.
After creating the component either manually or using cli following steps are
necessary to be performed:
1.now since we want the two components to be below under the first,therefore go to
app.component.html
file and add the open and close tags by the name which you gave to each components
selector,
For eg:
<appwarningalert></appwarningalert>
NOTE: remember the name of tag should be same as given to selectors.(when i tried
to change one of the tags name from its selectors name , it didnt gave
any compilation error but on browser the whole screen was blank mans gave no op. )
2.Now if u created the component then it would be added to the app.module.ts file
automatically.
if u created manually then go to app.module.ts file and in NgModule componentadd
the class name of the component.
NOTE: THE NAME WT=RITTEN IN THE @NGMODULE COMPONENT SHOULD BE SAME AS THE CLASS
NAME.
note: if u want to do styling either create .cc file for the component or in the
.ts file in the decorator do the styling in styles:
syntax: style [` p{
color:red;}
`]
doubt: i created a componenet called server and on browser it showed white page
until i added the html component in the
template in .ts file. in the decorator.
NOTE: If in template instead of adding the file externally , u simply write the
code written in html file then ,
whatever changes u make in html file u will ahve to do the same in .ts file in
temlplate to observe the changes.
NOTE: IF YOUR PORT IS BUSY THEN TO USE A DIFFERENT PORT FOR A PROJECT TYPE "ng
serve --port1234"or type "ng serve --open --port 4201".
note:whatever component u want to dispaly on browser that should be included in
app.component.html
LEC:SIGNING USERS
ERROR: auth service not found.
SOLUTION: open auth.service.ts
import { Injectable } from '@angular/core';
@Injectable()
NOTE:
the map imported in auth.service.ts ,if we compile after importing it there will be
compilation error ,but if we comment it out and then compile ,it compiles
successfully,
and after taht we again uncomment the import of map.
LAZY LOADING
if the user doesnt visits a part of our website then it becomes useless to load all
the code, therefore lazy loading means loading only when needed.
error:289 new recipie is not working