include ../_util-fns
a(id="top")
:marked
_Angular_ is the name for the Angular of today and tomorrow.
_AngularJS_ is the name for all v1.x versions of Angular.
This guide helps you transition from AngularJS to Angular
by mapping AngularJS syntax to the equivalent Angular syntax.
:marked
**See the Angular syntax in this
+makeExample('cb-ajs-quick-reference/ts/src/app/app.module.1.ts','','app.module.ts')(format="." )
:marked
Angular doesn't have a bootstrap directive.
To launch the app in code, explicitly bootstrap the application's root module (`AppModule`)
in `main.ts`
and the application's root component (`AppComponent`) in `app.module.ts`.
For more information see the [Setup](../guide/setup.html) page.
tr(style=top)
td
:marked
### ng-class
code-example(format="").
<div ng-class="{active: isActive}">
<div ng-class="{active: isActive,
shazam: isImportant}">
:marked
In AngularJS, the `ng-class` directive includes/excludes CSS classes
based on an expression. That expression is often a key-value control object with each
key of the object defined as a CSS class name, and each value defined as a template expression
that evaluates to a Boolean value.
In the first example, the `active` class is applied to the element if `isActive` is true.
You can specify multiple classes, as shown in the second example.
td
:marked
### ngClass
+makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'ngClass')(format="." )
:marked
In Angular, the `ngClass` directive works similarly.
It includes/excludes CSS classes based on an expression.
In the first example, the `active` class is applied to the element if `isActive` is true.
You can specify multiple classes, as shown in the second example.
Angular also has **class binding**, which is a good way to add or remove a single class,
as shown in the third example.
For more information see the [Attribute, class, and style bindings](../guide/template-syntax.html#other-bindings)
section of the [Template Syntax](../guide/template-syntax.html) page.
tr(style=top)
td
:marked
### ng-click
code-example(format="").
<button ng-click="vm.toggleImage()">
<button ng-click="vm.toggleImage($event)">
:marked
In AngularJS, the `ng-click` directive allows you to specify custom behavior when an element is clicked.
In the first example, when the user clicks the button, the `toggleImage()` method in the controller referenced by the `vm` `controller as` alias is executed.
The second example demonstrates passing in the `$event` object, which provides details about the event
to the controller.
td
:marked
### Bind to the `click` event
+makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'event-binding')(format="." )
:marked
AngularJS event-based directives do not exist in Angular.
Rather, define one-way binding from the template view to the component using **event binding**.
For event binding, define the name of the target event within parenthesis and
specify a template statement, in quotes, to the right of the equals. Angular then
sets up an event handler for the target event. When the event is raised, the handler
executes the template statement.
In the first example, when a user clicks the button, the `toggleImage()` method in the associated component is executed.
The second example demonstrates passing in the `$event` object, which provides details about the event
to the component.
For a list of DOM events, see: https://developer.mozilla.org/en-US/docs/Web/Events.
For more information, see the [Event binding](../guide/template-syntax.html#event-binding)
section of the [Template Syntax](../guide/template-syntax.html) page.
tr(style=top)
td
:marked
### ng-controller
code-example(format="").
<div ng-controller="MovieListCtrl as vm">
:marked
In AngularJS, the `ng-controller` directive attaches a controller to the view.
Using the `ng-controller` (or defining the controller as part of the routing) ties the
view to the controller code associated with that view.
td
:marked
### Component decorator
+makeExample('cb-ajs-quick-reference/ts/src/app/movie-list.component.ts', 'component')(format="." )
:marked
In Angular, the template no longer specifies its associated controller.
Rather, the component specifies its associated template as part of the component class decorator.
For more information, see [Architecture Overview](../guide/architecture.html#component).
tr(style=top)
td
:marked
### ng-hide
In AngularJS, the `ng-hide` directive shows or hides the associated HTML element based on
an expression. For more information, see [ng-show](#ng-show).
td
:marked
### Bind to the `hidden` property
In Angular, you use property binding; there is no built-in *hide* directive.
For more information, see [ng-show](#ng-show).
tr(style=top)
td
:marked
### ng-href
code-example(format="").
<a ng-href="angularDocsUrl">Angular Docs</a>
:marked
The `ng-href` directive allows AngularJS to preprocess the `href` property so that it
can replace the binding expression with the appropriate URL before the browser
fetches from that URL.
In AngularJS, the `ng-href` is often used to activate a route as part of navigation.
code-example(format="").
<a ng-href="#movies">Movies</a>
:marked
Routing is handled differently in Angular.
td
:marked
### Bind to the `href` property
+makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'href')(format="." )
:marked
Angular uses property binding; there is no built-in *href* directive.
Place the element's `href` property in square brackets and set it to a quoted template expression.
For more information see the [Property binding](../guide/template-syntax.html#property-binding)
section of the [Template Syntax](../guide/template-syntax.html) page.
In Angular, `href` is no longer used for routing. Routing uses `routerLink`, as shown in the following example.
+makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'router-link')(format="." )
:marked
For more information on routing, see the [RouterLink binding](../guide/router.html#router-link)
section of the [Routing & Navigation](../guide/router.html) page.
tr(style=top)
td
:marked
### ng-if
code-example(format="").
<table ng-if="movies.length">
:marked
In AngularJS, the `ng-if` directive removes or recreates a portion of the DOM,
based on an expression. If the expression is false, the element is removed from the DOM.
In this example, the `