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.
Services
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
binding data dependency directives services Templates