Angular: Templates, directives, data binding, Services and dependency injection
May 9, 2020

Introduction to Angular concepts Part 2

Templates directives

A template combines HTML with Angular markup that can modify HTML elements before they are displayed.

Template directives provide program logic.

Data binding

Binding markup connects your application data and the DOM.

There are two types of data binding:

1. Event Binding

2. Property Binding

Event binding lets your app respond to user input in the target environment by updating your application data.

Property binding lets you interpolate values that are computed from your application data into the HTML.

Angular evaluates the directives before a view is displayed.

It resolves the binding syntax in the template to modify the HTML elements and the DOM, according to your program data and logic.

Angular supports two-way data binding, meaning that changes in the DOM, such as user choices, are also reflected in your program data.

Your templates can use pipes to improve the user experience by transforming values for display.

For example, use pipes to display dates and currency values that are appropriate for a user’s locale.

Angular provides predefined pipes for common transformations, and you can also define your own pipes.


You create a service class for the data or logic that isn’t associated with a specific view, and that you want to share across components.

A service class definition is immediately preceded by the @Injectable() decorator.

The decorator provides the metadata that allows other providers to be injected as dependencies into your class.

Dependency injection

Dependency injection (DI) lets you keep your component classes lean and efficient by delegating tasks to services.

They don’t fetch data from the server, validate user input, or log directly to the console.

They delegate such tasks to services.

Credit: Angular.io


Leave a Reply

Most Read

#1 How to set opacity or transparency using CSS? #2 Pagination in CSS with multiple examples #3 How to check if radio button is checked or not using JavaScript? #4 How to make HTML form interactive and using CSS? #5 How to uninstall Cocoapods from the Mac OS? #6 How to add Read More Read Less Button using JavaScript?

Recently Posted

Feb 24 WordPress get_posts Examples Feb 24 How to modify the latest post array using get_posts() in WordPress? Feb 22 WordPress: How to get ACF field values from another post? Feb 22 WordPress: How to print ACF repeater field values? Feb 22 WordPress: How to print ACF array field values? Feb 21 WordPress: How to get field values in Advanced Custom Fields?

You might also like these

A quick introduction to API, REST API and PostmanMiscHow to Use SQL MAX() Function with Dates?SQL/MySQLCan We Use For Loop to Loop Through Associative Arrays in PHP?PHPIs monitoring an employee’s work on a computer a desirable or undesirable activity?Misc4 different ways to create JavaScript ObjectsJavaScriptHow to use HTML picture Tag?HTML