Angular Training + Practice Excercise
Angular Training + Practice Excercise
+ Practice Excercise
By Sushma
www.satvasolutions.com [email protected]
Contents
1. About angular
2. Environment Setup
3. Angular CLI
4. Evaluation of Angular
5. Angular Basics
4.1 Components
4.2 Module
4.3 Services
4.4 Dependency Injection
4.5 Decorator
6. Angular Data Binding
7. Routing
8. Angular Forms
9. Data Sharing between components
10. Pipes & Directives
11. Observables
12. HTTP Protocols
13. Best Practices for coding
14. ECMA 6 TypeScript
What is difference between UI/UX?
What is Angular?
Angular is an open-source, JavaScript framework written in TypeScript. Google maintains it, and its primary purpose is to develop
single-page applications. As a framework, Angular has clear advantages while also providing a standard structure for
developers to work with. It enables users to create large applications in a maintainable manner.
What is framework?
https://www.codecademy.com/resources/blog/what-is-a-framework/
Let's say you're building a house. You could pour the foundation and frame the house yourself. It would take a lot of time,
but you could do it. If all of that were already done for you, though, it would save you quite a bit of effort — especially if it
was done by expert home builders.
To install the CLI, in the command prompt, type the following commands
Installation:
npm install -g @angular/cli
Confirmation -
ng--version
Create angular first application
Step 1 : Create a folder for your application in the desired location on your system and open it on VSCode. Open a
new terminal and type in the following command to create your app folder.
ng new hello-world
Step 2 : To run the application, change the directory to the folder created, and use the ng command.
cd hello-world
ng serve
Once run, open your browser and navigate to localhost:4200. If another application is running on that address, you
can simply run the command.
Angular CLI
Angular CLI stands for Angular Command Line Interface. As the name implies, it is a command line tool for creating
angular apps. It is recommended to use angular cli for creating angular apps as you don't need to spend time installing
and configuring all the required dependencies and wiring everything together.
https://angular.io/cli
Why We Need Angular CLI?
Evolution Of Angular
https://angular-templates.io/tutorials/about/learn-angular-from-scratch-step-by-step
Folder Structure In Angular
Components
● Declarations: This one contains the name of components, pipes, and directives which are present in the NgModule.
● Imports: This contains the names of other modules whose functionalities are required by the components of this
particular module.
● Exports: This is responsible for making the component template visible to other modules that can import functionalities
from this Module.
● Providers: When NgModule runs, its main function is to provide the application with services. The provider is responsible
for creating Services that the NgModule requires. The services are accessible from all parts of the App.
● Bootstrap: This is the Property of Root Module. Bootstrapping is the process which initializes the root module. The root
module is responsible for initializing all the other modules.
Sample of module file
Angular module flow
Service
What is service?
Service is a piece of reusable code with a focused purpose. A code that you will use across multiple components in your
application
To define a class as a service in Angular, use the @Injectable() decorator to provide the metadata that allows Angular
to inject it into a component as a dependency.
Note : A dependency doesn't have to be a service—it could be a function, for example, or a value.
The Dependency Injection pattern involves 3 types of classes.
1. Client Class: The client class (dependent class) is a class which depends on the service class
2. Service Class: The service class (dependency) is a class that provides service to the client class.
3. Injector Class: The injector class injects the service class object into the client class.
Decorators
Decorators are a design pattern that is used to separate modification or decoration of a class without modifying the
original source code
https://ultimatecourses.com/blog/angular-decorators.
Types of Decorators:
3. Method Decorator(@HostListener)
Data binding allows Internet users to manipulate web page elements with the help of a web browser. It includes
dynamic HTML and does not require complex programming.
1. Interpolation Binding
2. Property Binding
3. Event Binding
https://www.pluralsight.com/guides/understandi
ng-purpose-routing-angular
1. Router Concept
2. Configuring The Router
3. Router Links
4. Route Parameters
5. Accessing Route Parameters
Angular Forms
Forms are an integral part of a web application. Practically every application comes with forms to be filled in by the users.
Angular forms are used to log in, update a profile, enter sensitive information, and perform many other data-entry tasks. In this
article, you will learn about how to create a form and validate the information filled.
● Template-Driven Approach
● Reactive Approach (For Array)
Template Driven Forms
https://angular.io/guide/forms
Reactive Forms
https://angular.io/guide/forms-overview
● With Reactive forms, the component directly manages the data flows between the form controls and
the data models.
● Reactive forms are code-driven, unlike the template-driven approach.
● Reactive forms break from the traditional declarative approach.
● Reactive forms eliminate the anti-pattern of updating the data model via two-way data binding.
In ts file :
1. NgIf,
2. NgFor,
3. NgSwitch.
Attribute Directive
Attribute directives manipulate the DOM by changing its behavior and appearance.
We use attribute directives to apply conditional style to elements, show or hide elements or dynamically change
the behavior of a component according to a changing property.
NgStyle Directive is an Attribute directive used to change the styling of any DOM element on the basis of some
condition.
http://jesidea.com/pakdb/angular-2-observables/
● What is Rxjs?
Basic Usage And Terms Of Observable
As a publisher, you create an Observable instance that defines a subscriber function. This is the function that is executed
when a consumer calls the subscribe() method. The subscriber function defines how to obtain or generate values or
messages to be published.
To execute the observable you have created and begin receiving notifications, you call its subscribe() method, passing an
observer. This is a JavaScript object that defines the handlers for the notifications you receive. The subscribe() call returns
a Subscription object that has an unsubscribe() method, which you call to stop receiving notifications.
Let’s take an example of create an observable
Here We Get (Subscribe) The Data Of Observable.
HTTP Protocols
● TypeScript programming
http: HttpClient) { }
● https://angular.io/guide/http
Intercepting Requests And Responses
Provide the interceptor:
{ provide: HTTP_INTERCEPTORS, useClass: NoopInterceptor, multi: true },
multi: true option. This required setting tells Angular that HTTP_INTERCEPTORS is a token for a multiprovider
that injects an array of values, rather than a single value.
Write Interceptor for Example
ECMAScript
ECMAScript is scripting-language specification standardized by Ecma International
ECMAScript 5,6
1. Card Name
2. Card due date
3. Card Description
4. Card percentage
5. Card assigned users()Define any 5 user yourself.
Exercise 9
Let’s create a movie ticket booking system please check to below demo url you need to do like this
http://ngtest.satva.solutions/sushma/movieBooking/#/movie-ticket-booking
Exercise 4
Design a cascading dropdown for country ,state and city.
Exercise 11
Design a page as explained in video for collapsed expand demo.
https://drive.google.com/file/d/1ZzIFC9vW5as0w73rCQ8kbm5tVHQC2s1M/view?usp=sharing
Exercise 12
Create a web chat application in ANGULAR
Exercise 12:- create a phone book app
Exercise 13 : Creating Reusable Angular Components
Follow the link and create by yourself using @input, @output , link :
https://medium.com/angular-in-depth/creating-reusable-angular-components-how-to-avoid-the-painful-trap-most-go-in-d531761d6c7a
Thanks for
Listening
www.satvasolutions.com [email protected]
+91 81530 04537 www.satvasolutions.com [email protected]