2016-02-05 23:27:06 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								include ../_util-fns
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								a(id="top")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								:marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  _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.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								:marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  **See the Angular syntax in this <live-example name="cb-ajs-quick-reference"></live-example>**.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  ## Contents
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  * [Template basics](#template-basics)—binding and local variables.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  * [Template directives](#template-directives)—built-in directives `ngIf` and `ngClass`.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  * [Filters/pipes](#filters-pipes)—built-in *filters*, known as *pipes* in Angular.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  * [Modules/controllers/components](#controllers-components)—*modules* in Angular are slightly different from *modules* in AngularJS, and *controllers* are *components* in Angular.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  * [Style sheets](#style-sheets)—more options for CSS than in AngularJS.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								.l-main-section
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								:marked
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  ## Template basics
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  Templates are the user-facing part of an Angular application and are written in HTML.
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  The following table lists some of the key AngularJS template features with their equivalent Angular template syntax.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								- var top="vertical-align:top"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								table(width="100%")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  col(width="50%")
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  col(width="50%")
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    th AngularJS
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    th Angular
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Bindings/interpolation
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								         Your favorite hero is: {{vm.favoriteHero}}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In AngularJS, an expression in curly braces denotes one-way binding.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        This binds the value of the element to a property in the controller
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        associated with this template.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        When using the `controller as` syntax,
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        the binding is prefixed with the controller alias (`vm` or `$ctrl`) because you
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        have to be specific about the source of the binding.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Bindings/interpolation
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/movie-list.component.html', 'interpolation')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In Angular, a template expression in curly braces still denotes one-way binding.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        This binds the value of the element to a property of the component.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The context of the binding is implied and is always the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        associated component, so it needs no reference variable.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information, see the [Interpolation](../guide/template-syntax.html#interpolation)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        section of the [Template Syntax](../guide/template-syntax.html) page.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Filters
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								         <td>{{movie.title | uppercase}}</td>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        To filter output in AngularJS templates, use the pipe character (|) and one or more filters.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        This example filters the `title` property to uppercase.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Pipes
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'uppercase')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In Angular you use similar syntax with the pipe (|) character to filter output, but now you call them **pipes**.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Many (but not all) of the built-in filters from AngularJS are
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        built-in pipes in Angular.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information, see [Filters/pipes](#filters-pipes) below.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Local variables
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example(format="").
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <tr ng-repeat="movie in vm.movies">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								          <td>{{movie.title}}</td>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        </tr>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Here, `movie` is a user-defined local variable.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2016-04-30 07:01:16 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Input variables
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'local')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Angular has true template input variables that are explicitly defined using the `let` keyword.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information, see the [ngFor micro-syntax](../guide/template-syntax.html#microsyntax)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        section of the [Template Syntax](../guide/template-syntax.html) page.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								:marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  [Back to top](#top)
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								.l-main-section
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								:marked
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  ## Template directives
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  AngularJS provides more than seventy built-in directives for templates.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  Many of them aren't needed in Angular because of its more capable and expressive binding system.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  The following are some of the key AngularJS built-in directives and their equivalents in Angular.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								table(width="100%")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  col(width="50%")
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  col(width="50%")
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    th AngularJS
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    th Angular
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ng-app
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <body ng-app="movieHunter">
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The application startup process is called **bootstrapping**.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Although you can bootstrap an AngularJS app in code,
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        many applications bootstrap declaratively with the `ng-app` directive,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        giving it the name of the application's module (`movieHunter`).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Bootstrapping
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/main.ts','','main.ts')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 17:38:25 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      <br>
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/app.module.1.ts','','app.module.ts')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 17:38:25 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Angular doesn't have a bootstrap directive.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        To launch the app in code, explicitly bootstrap the application's root module (`AppModule`)
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 17:38:25 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        in `main.ts`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        and the application's root component (`AppComponent`) in `app.module.ts`.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-21 17:13:21 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information see the [Setup](../guide/setup.html) page.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ng-class
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example(format="").
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <div ng-class="{active: isActive}">
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <div ng-class="{active: isActive,
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                           shazam: isImportant}">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In AngularJS, the `ng-class` directive includes/excludes CSS classes
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        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.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In the first example, the `active` class is applied to the element if `isActive` is true.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        You can specify multiple classes, as shown in the second example.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ngClass
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'ngClass')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In Angular, the `ngClass` directive works similarly.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        It includes/excludes CSS classes based on an expression.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In the first example, the `active` class is applied to the element if `isActive` is true.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        You can specify multiple classes, as shown in the second example.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Angular also has **class binding**, which is a good way to add or remove a single class,
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        as shown in the third example.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        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.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ng-click
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example(format="").
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <button ng-click="vm.toggleImage()">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <button ng-click="vm.toggleImage($event)">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In AngularJS, the `ng-click` directive allows you to specify custom behavior when an element is clicked.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        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.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The second example demonstrates passing in the `$event` object, which provides details about the event
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        to the controller.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Bind to the `click` event
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'event-binding')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        AngularJS event-based directives do not exist in Angular.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Rather, define one-way binding from the template view to the component using **event binding**.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For event binding, define the name of the target event within parenthesis and
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        specify a template statement, in quotes, to the right of the equals. Angular then
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        sets up an event handler for the target event. When the event is raised, the handler
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        executes the template statement.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In the first example, when a user clicks the button, the `toggleImage()` method in the associated component is executed.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The second example demonstrates passing in the `$event` object, which provides details about the event
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        to the component.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For a list of DOM events, see: https://developer.mozilla.org/en-US/docs/Web/Events.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information, see the [Event binding](../guide/template-syntax.html#event-binding) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        section of the [Template Syntax](../guide/template-syntax.html) page.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ng-controller
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example(format="").
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <div ng-controller="MovieListCtrl as vm">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In AngularJS, the `ng-controller` directive attaches a controller to the view.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Using the `ng-controller` (or defining the controller as part of the routing) ties the
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        view to the controller code associated with that view.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Component decorator
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/movie-list.component.ts', 'component')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In Angular, the template no longer specifies its associated controller.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Rather, the component specifies its associated template as part of the component class decorator.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information, see [Architecture Overview](../guide/architecture.html#component).
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ng-hide
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In AngularJS, the `ng-hide` directive shows or hides the associated HTML element based on
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        an expression. For more information, see [ng-show](#ng-show).
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Bind to the `hidden` property
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In Angular, you use property binding; there is no built-in *hide* directive.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information, see [ng-show](#ng-show).
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ng-href
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example(format="").
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <a ng-href="angularDocsUrl">Angular Docs</a>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The `ng-href` directive allows AngularJS to preprocess the `href` property so that it
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        can replace the binding expression with the appropriate URL before the browser
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        fetches from that URL.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In AngularJS, the `ng-href` is often used to activate a route as part of navigation.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example(format="").
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <a ng-href="#movies">Movies</a>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Routing is handled differently in Angular.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Bind to the `href` property
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'href')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Angular uses property binding; there is no built-in *href* directive.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Place the element's `href` property in square brackets and set it to a quoted template expression.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information see the [Property binding](../guide/template-syntax.html#property-binding) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        section of the [Template Syntax](../guide/template-syntax.html) page.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In Angular, `href` is no longer used for routing. Routing uses `routerLink`, as shown in the following example.
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'router-link')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information on routing, see the [RouterLink binding](../guide/router.html#router-link) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        section of the [Routing & Navigation](../guide/router.html) page.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ng-if
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example(format="").
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <table ng-if="movies.length">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In AngularJS, the `ng-if` directive removes or recreates a portion of the DOM,
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        based on an expression. If the expression is false, the element is removed from the DOM.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In this example, the `<table>` element is removed from the DOM unless the `movies` array has a length greater than zero.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### *ngIf
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/movie-list.component.html', 'ngIf')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The `*ngIf` directive in Angular works the same as the `ng-if` directive in AngularJS. It removes 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        or recreates a portion of the DOM based on an expression.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In this example, the `<table>` element is removed from the DOM unless the `movies` array has a length.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The (*) before `ngIf` is required in this example.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information, see [Structural Directives](../guide/structural-directives.html).
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ng-model
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example(format="").
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <input ng-model="vm.favoriteHero"/>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In AngularJS, the `ng-model` directive binds a form control to a property in the controller associated with the template.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        This provides **two-way binding**, whereby any change made to the value in the view is synchronized with the model, and any change to the model is synchronized with the value in the view.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ngModel
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/movie-list.component.html', 'ngModel')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In Angular, **two-way binding** is denoted by `[()]`, descriptively referred to as a "banana in a box". This syntax is a shortcut for defining both property binding (from the component to the view)
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        and event binding (from the view to the component), thereby providing two-way binding.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information on two-way binding with `ngModel`, see the [NgModel—Two-way binding to 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        form elements with `[(ngModel)]`](../guide/template-syntax.html#ngModel) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        section of the [Template Syntax](../guide/template-syntax.html) page.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ng-repeat
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example(format="").
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <tr ng-repeat="movie in vm.movies">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In AngularJS, the `ng-repeat` directive repeats the associated DOM element
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        for each item in the specified collection.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In this example, the table row (`<tr>`) element repeats for each movie object in the collection of movies.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### *ngFor
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/movie-list.component.html', 'ngFor')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The `*ngFor` directive in Angular is similar to the `ng-repeat` directive in AngularJS. It repeats 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        the associated DOM element for each item in the specified collection.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        More accurately, it turns the defined element (`<tr>` in this example) and its contents into a template and
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        uses that template to instantiate a view for each item in the list.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Notice the other syntax differences:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The (*) before `ngFor` is required;
							 
						 
					
						
							
								
									
										
										
										
											2016-04-30 07:01:16 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        the `let` keyword identifies `movie` as an input variable;
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        the list preposition is `of`, not `in`.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information, see [Structural Directives](../guide/structural-directives.html).
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ng-show
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example(format="").
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <h3 ng-show="vm.favoriteHero">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								          Your favorite hero is: {{vm.favoriteHero}}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        </h3>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In AngularJS, the `ng-show` directive shows or hides the associated DOM element, based on
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        an expression.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In this example, the `<div>` element is shown if the `favoriteHero` variable is truthy.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Bind to the `hidden` property
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/movie-list.component.html', 'hidden')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Angular uses property binding; there is no built-in *show* directive.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For hiding and showing elements, bind to the HTML `hidden` property.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        To conditionally display an element, place the element's `hidden` property in square brackets and
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        set it to a quoted template expression that evaluates to the *opposite* of *show*.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In this example, the `<div>` element is hidden if the `favoriteHero` variable is not truthy.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information on property binding, see the [Property binding](../guide/template-syntax.html#property-binding)  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        section of the [Template Syntax](../guide/template-syntax.html) page.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ng-src
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example(format="").
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <img ng-src="{{movie.imageurl}}">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The `ng-src` directive allows AngularJS to preprocess the `src` property so that it
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        can replace the binding expression with the appropriate URL before the browser
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        fetches from that URL.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Bind to the `src` property
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'src')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Angular uses property binding; there is no built-in *src* directive.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Place the `src` property in square brackets and set it to a quoted template expression.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information on property binding, see the [Property binding](../guide/template-syntax.html#property-binding)  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        section of the [Template Syntax](../guide/template-syntax.html) page.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ng-style
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example(format="").
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <div ng-style="{color: colorPreference}">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In AngularJS, the `ng-style` directive sets a CSS style on an HTML element
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        based on an expression. That expression is often a key-value control object with each
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        key of the object defined as a CSS property, and each value defined as an expression
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        that evaluates to a value appropriate for the style.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In the example, the `color` style is set to the current value of the `colorPreference` variable.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ngStyle
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'ngStyle')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In Angular, the `ngStyle` directive works similarly. It sets a CSS style on an HTML element based on an expression.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In the first example, the `color` style is set to the current value of the `colorPreference` variable.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Angular also has **style binding**, which is good way to set a single style. This is shown in the second example.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information on style binding, see the [Style binding](../guide/template-syntax.html#style-binding) section of the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        [Template Syntax](../guide/template-syntax.html) page.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information on the `ngStyle` directive, see [NgStyle](../guide/template-syntax.html#ngStyle) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        section of the [Template Syntax](../guide/template-syntax.html) page.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ng-switch
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example(format="").
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <div ng-switch="vm.favoriteHero &&
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        vm.checkMovieHero(vm.favoriteHero)">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            <div ng-switch-when="true">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								              Excellent choice!
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            </div>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            <div ng-switch-when="false">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								              No movie, sorry!
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            </div>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            <div ng-switch-default>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								              Please enter your favorite hero.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            </div>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        </div>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In AngularJS, the `ng-switch` directive swaps the contents of
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        an element by selecting one of the templates based on the current value of an expression.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In this example, if `favoriteHero` is not set, the template displays "Please enter ...".
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        If `favoriteHero` is set, it checks the movie hero by calling a controller method.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        If that method returns `true`, the template displays "Excellent choice!".
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        If that methods returns `false`, the template displays "No movie, sorry!".
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### ngSwitch
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/movie-list.component.html', 'ngSwitch')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In Angular, the `ngSwitch` directive works similarly.
							 
						 
					
						
							
								
									
										
										
										
											2016-06-21 03:03:31 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        It displays an element whose `*ngSwitchCase` matches the current `ngSwitch` expression value.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In this example, if `favoriteHero` is not set, the `ngSwitch` value is `null`
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        and `*ngSwitchDefault` displays, "Please enter ...".
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        If `favoriteHero` is set, the app checks the movie hero by calling a component method.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        If that method returns `true`, the app selects `*ngSwitchCase="true"` and displays: "Excellent choice!"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        If that methods returns `false`, the app selects `*ngSwitchCase="false"` and displays: "No movie, sorry!"
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-21 03:03:31 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The (*) before `ngSwitchCase` and `ngSwitchDefault` is required in this example.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information, see [The NgSwitch directives](../guide/template-syntax.html#ngSwitch) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        section of the [Template Syntax](../guide/template-syntax.html) page.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								:marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  [Back to top](#top)
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								a(id="filters-pipes")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								.l-main-section
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								:marked
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  ## Filters/pipes
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  Angular **pipes** provide formatting and transformation for data in the template, similar to AngularJS **filters**.
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  Many of the built-in filters in AngularJS have corresponding pipes in Angular.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  For more information on pipes, see [Pipes](../guide/pipes.html).
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								table(width="100%")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  col(width="50%")
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  col(width="50%")
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    th AngularJS
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    th Angular
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### currency
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <td>{{movie.price | currency}}</td>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Formats a number as currency.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### currency
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'currency')(format="." )
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The Angular `currency` pipe is similar although some of the parameters have changed.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### date
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
									
										
										
										
											2017-03-17 18:32:18 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <td>{{movie.releaseDate | date}}</td>
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Formats a date to a string based on the requested format.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### date
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'date')(format=".")
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The Angular `date` pipe is similar.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### filter
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <tr ng-repeat="movie in movieList | filter: {title:listFilter}">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Selects a subset of items from the defined collection, based on the filter criteria.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### none
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For performance reasons, no comparable pipe exists in Angular. Do all your filtering in the component. If you need the same filtering code in several templates, consider building a custom pipe.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### json
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <pre>{{movie | json}}</pre>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Converts a JavaScript object into a JSON string. This is useful for debugging.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### json
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'json')(format=".")
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The Angular `json` pipe does the same thing.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### limitTo
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
									
										
										
										
											2016-02-24 23:28:45 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <tr ng-repeat="movie in movieList | limitTo:2:0">
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2016-02-24 23:28:45 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Selects up to the first parameter (2) number of items from the collection
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        starting (optionally) at the beginning index (0).
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### slice
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'slice')(format=".")
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The `SlicePipe` does the same thing but the *order of the parameters is reversed*, in keeping
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        with the JavaScript `Slice` method.
							 
						 
					
						
							
								
									
										
										
										
											2016-02-24 23:28:45 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The first parameter is the starting index; the second is the limit.
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        As in AngularJS, coding this operation within the component instead could improve performance.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### lowercase
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <div>{{movie.title | lowercase}}</div>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Converts the string to lowercase.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### lowercase
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'lowercase')(format=".")
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The Angular `lowercase` pipe does the same thing.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### number
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
									
										
										
										
											2017-03-17 18:32:18 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <td>{{movie.starRating | number}}</td>
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Formats a number as text.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### number
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/app.component.html', 'number')(format=".")
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The Angular `number` pipe is similar.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        It provides more functionality when defining
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        the decimal places, as shown in the second example above.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Angular also has a `percent` pipe, which formats a number as a local percentage
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        as shown in the third example.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### orderBy
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <tr ng-repeat="movie in movieList | orderBy : 'title'">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Displays the collection in the order specified by the expression.
							 
						 
					
						
							
								
									
										
										
										
											2017-03-09 08:13:03 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In this example, the movie title orders the `movieList`.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### none
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For performance reasons, no comparable pipe exists in Angular.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Instead, use component code to order or sort results. If you need the same ordering or sorting code in several templates, consider building a custom pipe.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								:marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  [Back to top](#top)
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								a(id="controllers-components")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								.l-main-section
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								:marked
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  ## Modules/controllers/components
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  In both AngularJS and Angular, Angular modules help you organize your application into cohesive blocks of functionality.
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 17:38:25 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  In AngularJS, you write the code that provides the model and the methods for the view in a **controller**.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  In Angular, you build a **component**.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  Because much AngularJS code is in JavaScript, JavaScript code is shown in the AngularJS column.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  The Angular code is shown using TypeScript.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								table(width="100%")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  col(width="50%")
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  col(width="50%")
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    th AngularJS
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    th Angular
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### IIFE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        (function () {
							 
						 
					
						
							
								
									
										
										
										
											2016-02-24 23:28:45 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								          ...
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        }());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In AngularJS, an immediately invoked function expression (or IIFE) around controller code 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        keeps it out of the global namespace.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### none
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        This is a nonissue in Angular because ES 2015 modules 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        handle the namespacing for you.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information on modules, see the [Modules](../guide/architecture.html#modules) section of the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        [Architecture Overview](../guide/architecture.html).
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Angular modules
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        angular.module("movieHunter", ["ngRoute"]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In AngularJS, an Angular module keeps track of controllers, services, and other code. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The second argument defines the list of other modules that this module depends upon.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 17:38:25 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Angular modules
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/app.module.1.ts')(format=".")
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Angular modules, defined with the `NgModule` decorator, serve the same purpose:
							 
						 
					
						
							
								
									
										
										
										
											2017-03-31 15:25:27 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        * `imports`: specifies the list of other modules that this module depends upon
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        * `declaration`: keeps track of your components, pipes, and directives.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information on modules, see [Angular Modules (NgModule)](../guide/ngmodule.html).
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Controller registration
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        angular
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								          .module("movieHunter")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								          .controller("MovieListCtrl",
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                      ["movieService",
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                       MovieListCtrl]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        AngularJS has code in each controller that looks up an appropriate Angular module
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        and registers the controller with that module.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The first argument is the controller name. The second argument defines the string names of
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        all dependencies injected into this controller, and a reference to the controller function.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Component decorator
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/movie-list.component.ts', 'component')(format=".")
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        Angular adds a decorator to the component class to provide any required metadata.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The `@Component` decorator declares that the class is a component and provides metadata about
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        that component such as its selector (or tag) and its template.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        This is how you associate a template with logic, which is defined in the component class.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information, see the [Components](../guide/architecture.html#components) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        section of the [Architecture Overview](../guide/architecture.html) page.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Controller function
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        function MovieListCtrl(movieService) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In AngularJS, you write the code for the model and methods in a controller function.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Component class
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/movie-list.component.ts', 'class')(format=".")
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In Angular, you create a component class.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        NOTE: If you are using TypeScript with AngularJS, you must use the `export` keyword to export the component class.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information, see the [Components](../guide/architecture.html#components) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        section of the [Architecture Overview](../guide/architecture.html) page.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Dependency injection
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        MovieListCtrl.$inject = ['MovieService'];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        function MovieListCtrl(movieService) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In AngularJS, you pass in any dependencies as controller function arguments.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        This example injects a `MovieService`.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        To guard against minification problems, tell Angular explicitly
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        that it should inject an instance of the `MovieService` in the first parameter.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Dependency injection
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/movie-list.component.ts', 'di')(format=".")
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In Angular, you pass in dependencies as arguments to the component class constructor.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        This example injects a `MovieService`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        The first parameter's TypeScript type tells Angular what to inject, even after minification.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 16:27:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        For more information, see the [Dependency injection](../guide/architecture.html#dependency-injection) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        section of the [Architecture Overview](../guide/architecture.html).
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								:marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  [Back to top](#top)
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								a(id="style-sheets")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								.l-main-section
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								:marked
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  ## Style sheets
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  Style sheets give your application a nice look.
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  In AngularJS, you specify the style sheets for your entire application.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  As the application grows over time, the styles for the many parts of the application
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  merge, which can cause unexpected results.
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  In Angular, you can still define style sheets for your entire application. But now you can
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  also encapsulate a style sheet within a specific component.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								table(width="100%")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  col(width="50%")
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 21:20:33 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  col(width="50%")
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    th AngularJS
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    th Angular
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  tr(style=top)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Link tag
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      code-example.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        <link href="styles.css" rel="stylesheet" />
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        AngularJS, uses a `link` tag in the head section of the `index.html` file
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        to define the styles for the application.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    td
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### Link tag
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/index.html', 'style')(format=".")
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In Angular, you can continue to use the link tag to define the styles for your application in the `index.html` file.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        But now you can also encapsulate styles for your components.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        ### StyleUrls
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 03:26:11 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        In Angular, you can use the `styles` or `styleUrls` property of the `@Component` metadata to define
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        a style sheet for a particular component.
							 
						 
					
						
							
								
									
										
										
										
											2017-02-02 18:38:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      +makeExample('cb-ajs-quick-reference/ts/src/app/movie-list.component.ts', 'style-url')(format=".")
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      :marked
							 
						 
					
						
							
								
									
										
										
										
											2016-09-13 17:56:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
										 
									
								 
							
							
								        This allows you to set appropriate styles for individual components that won’  t leak into
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 14:49:02 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        other parts of the application.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								:marked
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  [Back to top](#top)