On Github jshamley / ng2presentation
Jeff Shamley / Shamley Incorporated / @jeff_shamley / jeffshamley.com
<p ng-repeat="item in items | filter">{{item.name}}</p>
<p ng-if="isActive">{{item.name}}</p>
<p *ng-for="#item of items | filter">{{item.name}}</p>
<p *ng-if="isActive" [item]="activeItem">{{item.name}}</p>
<input ng-value="itemValue" ng-model="itemValue" />
<input [value]="itemValue" (input)="itemValue" [placeholder]="itemValuePlaceholder" />
<input [(ng-model)]="itemValue" [placeholder]="itemValuePlaceholder" />
<button ng-click="getValue($val)">Click</button>
<button ng-keyup="$event.which === 13 && getValue($val)">Click</button>
<button (click)="getValue($val)">Click</button>
<button (keyup.enter)="getValue($val)">Click</button>
<p ng-show="visible">{{visibleItem | uppercase}}</p>
<p ng-hide="!visible">{{hiddenItem | uppercase}}</p>
<p [hidden]="!visible">{{togglableItem | uppercase}}</p>
import {Component, View} from 'angular2/angular2'; // Annotation section @Component({ selector: 'example' }) @View({ templateUrl: './components/example/example.html' }) // Component Controller export class Example { constructor() { this.name = "John Smith"; } }
import {Injectable} from 'angular2/core'; @Injectable() export class Title { value: string; constructor() { this.value = 'Angular 2'; } }
import {Title} from './../services/title';
import {Directive, ElementRef, Renderer} from 'angular2/core'; @Directive({ selector: '[directive]' }) export class MyDirective { text: string; constructor() { this.text = 'My Directive'; } }
import {RouteConfig, Router, ROUTER_DIRECTIVES} from 'angular2/router'; @RouteConfig([ { path: '/:myParam', component: MyComponent, as: 'MyCmp' }, { path: '/staticPath', component: ..., as: ...}, { path: '/*wildCardParam', component: ..., as: ...} ]) class MyComponent() {}
import {Http, HTTP_PROVIDERS} from 'angular2/http'; @Component({ selector: 'http-app', viewProviders: [HTTP_PROVIDERS] }) class PeopleComponent { constructor(http: Http) { http.get('people.json') .map(res => res.json()) .subscribe(people => this.people = people); } }
Jeff Shamley / Shamley Incorporated / @jeff_shamley / jeffshamley.com