12. Angular
12. Angular
----------------
Angular Framework
-----------------
- Angular is typescript based open source front end web application platform
JavaScript vs TypeScript
------------------------
Ex:
JavaScript
----------
TypeScript
----------
n : number = 10;
flag : boolean;
Angular Setup
-------------
- Node JS
To Download
-----------
url: nodejs.org
To verify Node JS
-----------------
C:\>node -v
-v => version
C:\>npm -v
- Sublime Text
To download Visual Studio Code
------------------------------
url: code.visualstudio.com/download
- Angular/CLI
url: cli.angular.io
To install Angular/CLI
----------------------
To verify
----------
C:\>ng version
ng => angular
---------------------------
C:\>cd Angular
----------------------
C:\Angular>cd Angular-Project
C:\Angular\Angular-Project>ng serve
http://localhost:4200
- When a request is made to an Angular Project, the server loads, index.html file
- In index.html, using the element <app-root>, it loads the app component (app.component.ts) file
Refer programs
- app.component.ts
- app.component.html
- app.component.css
To terminate the compilation => ctrl + c
Date:07/Feb/2023
----------------
Angular Directives
-------------------
Example Application
-------------------
Refer programs
- address.component.ts
- address.component.html
- address.component.css
- app.component.html (updated)
Angular Forms
-------------
Angular Forms are used to accept the user input and submit the form data to
the component
To use Angular Forms we need to add "FormsModule" in app.module.ts file
Example Application
-------------------
or
Refer programs
- book.component.html
- book.component.ts
- app.component.html (updated)
Angular Routing
---------------
Example Application
-------------------
>ng g c about
>ng g c dashboard
>ng serve
http://localhost:4200
Date:08/Feb/2023
----------------
-------------------------
HttpClient module of Angular is used to invoke the services which are running
Ex:
httpClient : HttpClient;
httpClient.get("http://localhost:8080/api/employees/allemployees");
Java Side
----------
Name : SpringAngularProj
Java Version : 8
Group : springangular
Artifact : SpringAngularProj
Package : com.spring.angular
Click Next
- Spring Web
- Lombok
- MySQL Driver
Note
----
- Update application.properties
Angular Side
------------
>ng g c employee
REfer programs
- employee.component.html
- employee.component.ts
- Update app.module.ts file by adding "HttpClientModule"
>ng serve
http://localhost:4200