Welcome to the Angular Tutorial. This Tutorial covers all versions of Angular Starting from Angular 2, Angular 4, Angular 5, Angular 6, Angular 7, Angular 8, Angular 9 We have created a simple and step by step tutorial for beginners to learn all the features of the Angular. The tutorial also covers some of the advanced features of Angular
This Tutorial Applies to Angular 2 Tutorial, Angular 4 Tutorial, Angular 5 Tutorial, Angular 6 Tutorial & Angular 7 Tutorial, Angular 8 Tutorial, Angular 9 Tutorial
Table of Content
- What is Angular
- Table of Content
- Angular Resources
What is Angular
The Angular is the latest version of the AngularJS, which is a development platform for building mobile and desktop web applications. The Angular now comes with every feature you need to build a complex and sophisticated web or mobile application. It comes with features like component, Directives, Forms, Pipes, HTTP Services, Dependency Injection, etc
The early version of the Angular was named as Angular 2. Then later it was renamed to just Angular. Then Angular Team releases new versions of the Angular versions Regularly and the last stable version that is available is Angular 8.2.14
The Angular 9 Beta version is released on 25.09.2019
|Angular 2||14.09.2016||Initial Version of Angular|
|Angular 4||23.03.2017||Version 4|
|Angular 5||11.11.2017||Version 5|
|Angular 6||03-05-2018||Version 6|
|Angular 7||18-10-2018||Version 7|
|Angular 8||25-08-2019||Version 8|
You can read the latest versions at https://github.com/angular/angular/blob/master/CHANGELOG.md
We are going to use Typescript as our language. If you have knowledge of C# or Java, then you would find it very easy. Take a look at the Typescript Tutorial
Table of Content
Introduction to Angular
The AngularJs was very easy to set up and get started. It was not the case with when the Angular came out with the version Angular 2. But now since the Angular 7, installing and creating a new project in angular has become very simple. The only thing you need to do in install and Visual Studio code, NPM Package manager & Angular CLI. Once, you install the required dependencies, creating a new project is as easy as running a simple command
ng new. Angular CLI takes care of Configuration & initialization of various libraries.
The following step by step tutorial will take you through the process of creating an Angular application
- Installing and Setting Up an Angular Development Environment
- How to Create a new project in Angular
- Bootstrapping in Angular
The Component passes the data to the view using a process called Data Binding. This is done by Binding the DOM Elements to component properties. Binding can be used to display component class property values to the user, change element styles, respond to a user event, etc.
The Angular directive helps us to manipulate the DOM. You can change the appearance, behavior or layout of a DOM element using the directives. They help you to extend HTML. The Angular directives are classified into three categories based on how they behave. They are Component, Structural and Attribute Directives
The ngClass Directive is an Angular Attribute Directive, which allows us to add or remove CSS classes to an HTML element. The ngStyle directive allows you to modify the style of an HTML element using the expression. Using the ngStyle you can dynamically change the style of your HTML element.
The Angular pipes are used to Transform the Data. For Example, the Date pipe formats the date according to locale rules. We can pass arguments to pipe and chain pipes. The Angular also allows us to create the Custom Pipe
The Components are useless if they do not share data between them. The Parent Component communicates with the child component using the @Input Annotation. The child components detect changes to these Input properties using OnChanges life Cycle hook or with a Property Setter. The child component can communicate with the parent by raising an event, which the parent can listen.
Component Life Cycle Hook
The life cycle hooks are the methods that angular invokes on directives and components as it creates, changes, and destroys them. Using life-cycle hooks we can fine-tune the behavior of our components during creation, update, and destruction.
The data entry forms can be very simple to very complex. The Forms contains large no of input fields, a variety of fields like Text boxes, Dates, Numbers, Emails, Password, Check Boxes, Option boxes, etc. These fields can Span multiple tabs or multiple pages. Forms may also contain complex validation logic interdependent on multiple fields.
The Angular forms modules are designed to handle all of the above and a lot more. The Angular Forms now supports Reactive forms approach to Forms development. The older way of Template-based approach is also supported
- Angular Forms Tutorial: Fundamental & Concepts
- Template Driven Forms in Angular
- Set Value in Template Driven forms in Angular
- Reactive Forms in Angular
- FormBuilder in Reactive Forms
- SetValue & PatchValue in Angular
- StatusChanges in Angular Forms
- ValueChanges in Angular Forms
- FormArray Example
- Build Dynamic or Nested Forms using FormArray
Services & Dependency Injection
Services allow us to create reusable code and use it every component that needs it. The Services can be injected into components and other services using the dependency injection system. The dependencies are declared in the Module using the Providers metadata. The Angular creates a tree of injector & Providers that resembles the Component Tree. This is called the hierarchical pattern.
- Dependency injection
- Injector, @Injectable & @Inject
- Hierarchical Dependency Injection
Angular Forms Validation
One of the common tasks that is performed, while building a form is Validation. The Forms Validation is built into the Angular Forms Module. The Angular provides several Built-in validators out of the box. If those validators do not fit your needs, then you can create your own custom validator.
- Validations in Reactive Forms in Angular
- Custom Validator in Reactive Forms
- Passing Parameter to Custom Validator in Reactive Forms
- Inject Service into Custom Validator
- Validation in Template Driven Forms
- Custom Validator in Template Driven Forms
The newly designed HttpClient Module allows us to query the Remote API source to get data into our Application. It requires us to Subscribe to the returned response using RxJs observables.
The Router module handles the navigation & Routing in Angular. The Routing allows you to move from one part of the application to another part or one View to another View.
- Routing and Navigation in Angular
- Location Strategies in Angular Router
- Passing Parameters to Route
- Child Routes / Nested Routes
- Passing Optional (Query) Parameters to a route
- Navigation between Routes
- Angular Route Guards
- CanActivate Guard
- CanActivateChild Guard
- CanDeactivate Guard
- Angular Resolve Guard
- Angular Pass data to route
- Introduction to Angular Modules
- Routing Between Angular Modules
- Angular folder structure: Best Practices
- Lazy Loading in Angular
- Preloading Strategy
- CanLoad Guard
Styling the Application
The Angular uses several different ways to style the Application. You can style the app globally and then override it locally in the component very easily. The component styles have local scope, which is achieved using the various View Encapsulation strategies. Learn all these in the section
- Angular Global Styles
- View Encapsulation
- Style binding in Angular
- Class Binding in Angular
- Component Styles
Learn how to use Angular CLI to speed up the development of Angular Application
The Angular application can use either SystemJs or Webpack module loader. We will demonstrate how to make use of both the Loader by building a small application.