Angular 2 Glossary
Angular 2 has a vocabulary of its own. Most Angular 2 terms are everyday English words with a specific meaning within the Angular system.
We have gathered here the most prominent terms and a few less familiar ones that have unusual or unexpected definitions.
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Annotation
When unqualified, annotation refers to a Dart metadata
annotation (as opposed to, say, a type annotation). A metadata
annotation begins with the character @
, followed by either a reference
to a compile-time constant (such as Component
) or a call
to a constant constructor. See the Dart Language Guide for
details.
The corresponding term in TypeScript and JavaScript is decorator.
Attribute Directive
A category of Directive that can listen to and modify the behavior of other HTML elements, attributes, properties, and components. They are usually represented as HTML attributes, hence the name.
The ngClass
directive for adding and removing CSS class names is a good example of
an Attribute Directive.
Binding
Almost always refers to Data Binding and the act of binding an HTML object property to a data object property.
May refer to a Dependency Injection binding between a "token" or "key" and a dependency provider. This more rare usage should be clear in context.
Bootstrap
We launch an Angular application by "bootstrapping" it with the
bootstrap method. The bootstrap
method identifies an
application's top level "root" Component and optionally
registers service providers with the dependency injection
system.
One can bootstrap multiple apps in the same index.html
, each with its own top level root.
camelCase
The practice of writing compound words or phrases such that each word or abbreviation begins with a capital letter except the first letter which is a lowercase letter.
Function, property, and method names are typically spelled in camelCase. Examples include: square
, firstName
and getHeroes
.
This form is also known as lower camel case, to distinguish it from upper camel case which we call PascalCase. When we write "camelCase" in this documentation we always mean lower camel case.
Component
An Angular class responsible for exposing data to a View and handling most of the view’s display and user-interaction logic.
The Component is one of the most important building blocks in the Angular system. It is, in fact, an Angular Directive with a companion Template.
The developer applies the @Component
annotation to
the component class, thereby attaching to the class the essential component metadata
that Angular needs to create a component instance and render it with its template
as a view.
Those familiar with "MVC" and "MVVM" patterns will recognize the Component in the role of "Controller" or "View Model".
dash-case
The practice of writing compound words or phrases such that each word is separated by a dash or hyphen (-
).
This form is also known as kebab-case.
Directive selectors (like my-app
) and
the root of filenames (such as hero-list.component.ts
) are often
spelled in dash-case.
Data Binding
Applications display data values to a user and respond to user actions (clicks, touches, keystrokes).
We could push application data values into HTML, attach event listeners, pull changed values from the screen, and update application data values ... all by hand.
Or we could declare the relationship between an HTML widget and an application data source ... and let a data binding framework handle the details.
Data Binding is that second approach. Angular has a rich data binding framework with a variety of data binding operations and supporting declaration syntax.
The many forms of binding include:
- Interpolation
- Property Binding
- Event Binding
- Attribute Binding
- Class Binding
- Style Binding
- Two-way data binding with ngModel
Learn more about data binding in the Template Syntax chapter.
Decorator | Decoration
When used in this guide, these JavaScript terms are taken as synonymous with annotation.
Dependency Injection
Dependency Injection is both a design pattern and a mechanism for creating and delivering parts of an application to other parts of an application that request them.
Angular developers prefer to build applications by defining many simple parts that each do one thing well and then wire them together at runtime.
These parts often rely on other parts. An Angular Component part might rely on a service part to get data or perform a calculation. When a part "A" relies on another part "B", we say that "A" depends on "B" and that "B" is a dependency of "A".
We can ask a "Dependency Injection System" to create "A" for us and handle all the dependencies. If "A" needs "B" and "B" needs "C", the system resolves that chain of dependencies and returns a fully prepared instance of "A".
Angular provides and relies upon its own sophisticated Dependency Injection system to assemble and run applications by "injecting" application parts into other application parts where and when needed.
At the core there is an Injector
that returns dependency values on request.
The expression injector.get(token)
returns the value associated with the given token.
A token is an Angular type (OpaqueToken
). We rarely deal with tokens directly; most
methods accept a class name (Foo
) or a string ("foo") and Angular converts it
to a token. When we write injector.get(Foo)
, the injector returns
the value associated with the token for the Foo
class, typically an instance of Foo
itself.
Angular makes similar requests internally during many of its operations
as when it creates a Component
for display.
The Injector
maintains an internal map of tokens to dependency values.
If the Injector
can't find a value for a given token, it creates
a new value using a Provider
for that token.
A Provider is a recipe for creating new instances of a dependency value associated with a particular token.
An injector can only create a value for a given token if it has
a Provider
for that token in its internal provider registry.
Registering providers is a critical preparatory step.
Angular registers some of its own providers with every injector. We can register our own providers.
Learn more in the Dependency Injection chapter.
Directive
An Angular class responsible for creating, re-shaping, and interacting with HTML elements in the browser DOM. Directives are Angular's most fundamental feature.
A Directive is almost always associated with an HTML element or attribute. We often refer to such an element or attribute as the directive itself. When Angular finds a directive in an HTML template, it creates the matching directive class instance and gives that instance control over that portion of the browser DOM.
Developers can invent custom HTML markup (e.g., <my-directive>
) to
associate with their custom directives. They add this custom markup to HTML templates
as if they were writing native HTML. In this way, directives become extensions of
HTML itself.
Directives fall into one of three categories:
Components that combine application logic with an HTML template to render application [views]. Components are usually represented as HTML elements. They are the building blocks of an Angular application and the developer can expect to write a lot of them.
Attribute Directives that can listen to and modify the behavior of other HTML elements, attributes, properties, and components. They are usually represented as HTML attributes, hence the name.
Structural Directives, a directive responsible for shaping or re-shaping HTML layout, typically by adding, removing, or manipulating elements and their children.
ECMAScript
The official JavaScript language specification.
The latest approved version of JavaScript is ECMAScript 2016 (AKA "ES2016" or "ES7") and many Angular 2 developers will write their applications either in this version of the language or a dialect that strives to be compatible with it such as TypeScript.
Most modern browsers today only support the much older "ECMAScript 5" (AKA ES5) standard. Applications written in ES2016, ES2015 or one of their dialects must be "transpiled" to ES5 JavaScript.
Angular 2 developers may choose to write in ES5 directly.
ES2015
Short hand for "ECMAScript 2015".
ES6
Short hand for "ECMAScript 2015".
ES5
Short hand for "ECMAScript 5", the version of JavaScript run by most modern browsers. See ECMAScript.
Injector
An object in the Angular dependency injection system that can find a named "dependency" in its cache or create such a thing with a registered provider.
Input
A directive property that can be the target of a Property Binding. Data values flow into this property from the data source identified in the template expression to the right of the equal sign.
See the Template Syntax chapter.
Interpolation
A form of Property Data Binding in which a template expression between double-curly braces renders as text. That text may be concatenated with neighboring text before it is assigned to an element property or displayed between element tags as in this example.
Learn more about interpolation in the Template Syntax chapter.
kebab-case
See dash-case.
Lifecycle Hooks
Directives and Components have a lifecycle managed by Angular as it creates, updates and destroys them.
Developers can tap into key moments in that lifecycle by implementing one or more of the "Lifecycle Hook" interfaces.
Each interface has a single hook method whose name is the interface name prefixed with ng
.
For example, the OnInit
interface has a hook method names ngOnInit
.
Angular calls these hook methods in the following order:
ngOnChanges
- called when an input/output binding values changengOnInit
- after the firstngOnChanges
ngDoCheck
- developer's custom change detectionngAfterContentInit
- after component content initializedngAfterContentChecked
- after every check of component contentngAfterViewInit
- after component's view(s) are initializedngAfterViewChecked
- after every check of a component's view(s)ngOnDestroy
- just before the directive is destroyed.
Learn more in the Lifecycle Hooks chapter.
Module
In this guide, the term module refers to a Dart compilation unit, such
as a library, or a package. (If a Dart file has no library
or part
directive, then that file itself is a library and thus a compilation
unit.) For more information about compilation units, see
the chapter on "Libraries and Scripts" in the
Dart Language Specification.
Output
A directive property that can be the target of an Event Binding. Events stream out of this property to the receiver identified in the template expression to the right of the equal sign.
See the Template Syntax chapter.
PascalCase
The practice of writing compound words or phrases such that each word or abbreviation begins with a capital letter.
Class names are typically spelled in PascalCase. Examples include: Person
and HeroDetailComponent
.
This form is also known as upper camel case, to distinguish it from lower camel case which we simply call camelCase. In this documentation, "PascalCase" means upper camel case and "camelCase" means lower camel case.
Pipe
An Angular pipe is a function that transforms input values to output values for
display in a view. We use the @Pipe
annotation
to associate the pipe function with a name. We can then use that
name in our HTML to declaratively transform values on screen.
Here's an example that uses the built-in currency
pipe to display
a numeric value in the local currency.
Learn more in the chapter on pipes .
Provider
A Provider creates a new instance of a dependency for the Dependency Injection system. It relates a lookup token to code — sometimes called a "recipe" — that can create a dependency value.
Router
Most applications consist of many screens or views. The user navigates among them by clicking links and buttons and taking other similar actions that cause the application to replace one view with another.
The Angular Component Router is a richly featured mechanism for configuring and managing the entire view navigation process including the creation and destruction of views.
Routing Component
A Component with an attached router.
In most cases, the component became attached to a router by means
of a @RouterConfig
that defined routes to views controlled by this component.
The component's template has a RouterOutlet
element where it can display views produced by the router.
It likely has anchor tags or buttons with RouterLink
directives that users can click to navigate.
snake_case
The practice of writing compound words or phrases such that each word is separated by an
underscore (_
). This form is also known as underscore case.
Library and file names are often spelled in snake_case. Examples include:
angular2_tour_of_heroes
and app_component.dart
.
Service
Components are great and all, but what do we do with data or logic that are not associated with a specific view or that we want to share across components? We build services!
Applications often require services such as a hero data service or a logging service. Our components depend on these services to do the heavy lifting.
A service is a class with a focused purpose. We often create a service to implement features that are independent from any specific view, provide share data or logic across components, or encapsulate external interactions.
See the Services chapter of the tutorial to learn more.
Structural Directive
A category of Directive that can shape or re-shape HTML layout, typically by adding, removing, or manipulating elements and their children.
The ngIf
"conditional element" directive and the ngFor
"repeater" directive are
good examples in this category.
See the Structural Directives chapter to learn more.
Template
A template is a chunk of HTML that Angular uses to render a view with the support and continuing guidance of an Angular Directive, most notably a Component.
We write templates in a special Template Syntax.
Template Expression
An expression is a Dart-like syntax that Angular evaluates within a data binding. Learn how to write template expressions in the Template Syntax chapter.
Transpile
The process of transforming code written in one form of JavaScript (e.g., TypeScript) into another form of JavaScript (e.g., ES5).
TypeScript
A version of JavaScript that supports most ECMAScript 2015 language features and many features that may arrive in future versions of JavaScript such as Decorators.
TypeScript is also noteable for its optional typing system which gives us compile-time type-checking and strong tooling support (e.g. "intellisense", code completion, refactoring, and intelligent search). Many code editors and IDEs support TypeScript either natively or with plugins.
TypeScript is the preferred language for Angular 2 development although we are welcome to write in other JavaScript dialects such as ES5.
Learn more about TypeScript on its website.
View
A view is a portion of the screen that displays information and responds to user actions such as clicks, mouse moves, and keystrokes.
Angular renders a view under the control of one or more Directives, especially Component directives and their companion Templates. The Component plays such a prominent role that we often find it convenient to refer to a component as a view.
Views often contain other views and any view might be loaded and unloaded dynamically as the user navigates through the application, typically under the control of a router.
Zone
Zones are a mechanism for encapsulating and intercepting a Dart application's asynchronous activity.
To learn more, consult the zones article.