2015-04-22 05:42:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								.statement
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  h4 Live Examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  p.
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 07:21:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    If you want to skip to the working examples you can check out these links on Plunker. <a href='http://plnkr.co/edit/htvpvg2RxemT2W0mYu0y?p=preview')> TypeScript Example</a> or <a href='http://plnkr.co/edit/sjRKtQd10ARLM2GTsQKi?p=preview'> ES5 Example</a>.
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 05:25:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 05:42:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								.l-main-section
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 06:03:21 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  h2#section-responding-to-user-input Responding to user input with event syntax
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 07:21:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  p.
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 06:03:21 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    You can make your application respond to user input by using the event syntax. The event syntax starts with an event name surrounded by parenthesis: <code>(event)</code>. A controller function is then assigned to the event name: <code>(event)="controllerFn()"</code>.
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  p.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    For a particular control like an input you can have it call methods on your controller on keyup event like so:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  pre.prettyprint.lang-html
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    code.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      <input (keyup)="myControllerMethod()">
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 07:21:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 06:03:21 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  h3#local-variables Local variables
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  p.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    As in previous examples, you can make element references available to other parts of the template as a local
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 05:25:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    variable using the <code>#var</code> syntax.  With this and events, we can do the old "update text as you type" example:
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  pre.prettyprint.lang-html
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    code.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      <input #myname (keyup)>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      <p>{{myname.value}}</p>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  p.text-body(ng-non-bindable).
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 05:25:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    The <code>#myname</code> creates a local variable in the template that we'll refer to below in the
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    <code><p></code> element.  The <code>(keyup)</code> tells Angular to trigger updates when it gets a keyup
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 05:25:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    event.  And the <code>{{myname.value}}</code> binds the text node of the  <code><p></code> element to the
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    input's value property.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  p Let's do something a little more complex where users enter items and add them to a list like this:
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 07:21:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  figure.image-display
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      img(src='user-input-example1.png')
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 15:12:29 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 05:25:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								.l-ain-section
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  h2#section-create-an-array-property Create an array property
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  p.
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 05:25:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    With the default bootstrapping in place, create a controller class that will manage interactions with the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    list. Inside the controller, add an array with an initial list of items.  Then add a method that pushes new items
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    on the array when called.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 07:21:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  .code-box
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    pre.prettyprint.linenums.lang-javascript(data-name="es5")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      code.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //ES5
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        function TodoList() {
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 15:12:29 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          this.todos = ["Eat Breakfast", "Walk Dog", "Breathe"];
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 07:21:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          this.addTodo = function(todo) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this.todos.push(todo);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          };
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 15:12:29 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 07:21:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    pre.prettyprint.linenums.lang-typescript(data-name="typescript")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      code.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //TypeScript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        class TodoList {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          todos: Array<string>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          constructor() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this.todos = ["Eat Breakfast", "Walk Dog", "Breathe"];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          addTodo(todo: string) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this.todos.push(todo);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          }
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								.callout.is-helpful
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  header Production Best Practice
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  p.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      As with the previous example, in a production application you will separate your model out into another class
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 05:25:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      and inject it into <code>TodoList</code>.  We've omitted it here for brevity.
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								.l-main-section
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  h2#section-display-the-list-of-todos Display the list of todos
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  p.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    Using the <code>*for</code> iterator, create an <code><li></code> for each item in the todos array and set
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    its text to the value.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  pre.prettyprint.linenums.lang-html
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    code.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      <ul>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         <li *for="#todo of todos">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								           {{ todo }}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         </li>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      </ul>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								.l-main-section
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  h2#section-add-todos-to-the-list Add todos to the list via button click
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  p.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    Now, add a text input and a button for users to add items to the list.  As you saw above, you can create a local
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    variable reference in your template with <code>#varname</code>.  Call it <code>#todotext</code> here.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  pre.prettyprint.lang-html
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    code.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      <input #todotext>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  p.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    Lastly, specify the target of the click event binding as your controller's <code>addTodo()</code> method and pass
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    it the value. Since you created a reference called <code>todotext</code>, you can get the value with
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 06:03:21 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    <code>todotext.value.</code>
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  pre.prettyprint.lang-html
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    code.
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 06:03:21 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        <button (click)="addTodo(todotext.value)">Add Todo</button>
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 05:25:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  p And then create the <code>doneTyping()</code> method on TodoList and handle adding the todo text.
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  pre.prettyprint.lang-javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    code.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      doneTyping($event) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if($event.which === 13) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          this.addTodo($event.target.value);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          $event.target.value = null;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								.l-main-section
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  h2#section-final-code Final Code
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 07:21:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  .code-box
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    pre.prettyprint.lang-javascript(data-name="es5")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      code.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //ES5
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        function TodoList() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          this.todos = ["Eat Breakfast", "Walk Dog", "Breathe"];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          this.addTodo = function(todo) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this.todos.push(todo);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          };
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          this.doneTyping = function($event) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if($event.which === 13) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              this.addTodo($event.target.value);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              $event.target.value = null;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 15:12:29 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          }
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 07:21:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        TodoList.annotations = [
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          new angular.Component({
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            selector: "todo-list"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          }),
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          new angular.View({
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            template:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              '<ul>' +
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              '<li *for="#todo of todos">' +
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              '{{ todo }}' +
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              '</li>' +
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              '</ul>' +
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              '<input #textbox (keyup)="doneTyping($event)">' +
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              '<button (click)="addTodo(textbox.value)">Add Todo</button>',
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            directives: [angular.For, angular.If]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        document.addEventListener("DOMContentLoaded", function() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          angular.bootstrap(TodoList);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        });
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    pre.prettyprint.lang-typescript(data-name="typescript")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      code.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //TypeScript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        import {Component, View, bootstrap, For, If} from 'angular2/angular2';
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        @Component({
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          selector: 'todo-list'
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        })
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 07:21:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        @View({
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          template: `
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            <ul>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              <li *for="#todo of todos">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                {{ todo }}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              </li>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            </ul>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            <input #todotext (keyup)="doneTyping($event)">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            <button (click)="addTodo(todotext.value)">Add Todo</button>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                  `,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          directives: [For, If]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        class TodoList {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          todos: Array<string>;
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 07:21:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          constructor() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this.todos = ["Eat Breakfast", "Walk Dog", "Breathe"];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          }
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 07:21:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          addTodo(todo: string) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this.todos.push(todo);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          }
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 07:21:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          doneTyping($event) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if($event.which === 13) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              this.addTodo($event.target.value);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              $event.target.value = null;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 15:12:29 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 16:04:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 07:21:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        bootstrap(TodoList);