Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Intro to Angular 2

Intro to Angular 2

Angular 2 basics introduction:
- setup
- app architecture
- component
- inputs and outputs
- built in directives
- change detection
- services
- routing

Presented in front of IDF soldiers of the intelligence department.

Shmuela Jacobs

August 31, 2016
Tweet

More Decks by Shmuela Jacobs

Other Decks in Technology

Transcript

  1. Shmuela Jacobs - BSc in Physics, MSc in IM -

    Owns a deaf dog 
 and a one-eyed cat - Got here with her classic VW Sr. Web Developer @ 500Tech
  2. Angular 2 Newest technology Built on top of the vast

    experience and success of Angular 1 Fast, robust Lots of (expected) users Supported by large companies Targets various platforms: web, mobile... Simple, clean, fun! -why?
  3. JavaScript + Types TypeScript ES6 (ES-2015) JavaScript (ES5) • type

    checking
 string, number, boolean, any, Array<T> • custom types - interfaces • code help - intellisense • decorators • and more... Typescript: Angular 2's Secret Weapon - Dan Wahlin
  4. 
 
 
 
 class Dog { age = 0;


    children = [];
 
 talk(times: number) {
 const bark = 'Ruff! ';
 return bark.repeat(times);
 }
 }
 
 let Ziggi = new Dog();
 console.log(Ziggi.talk(3)); TypeScript + tooling
  5. interface Animal {
 age: number,
 children: Array<Animal>,
 talk(times: number): string


    } class Dog implements Animal { age = 0;
 children = [];
 
 talk(times: number) {
 const bark = 'Ruff! ';
 return bark.repeat(times);
 }
 }
 
 let Ziggi = new Dog();
 console.log(Ziggi.talk(3)); TypeScript + tooling
  6. E-Store search 4 <header>
 <a href="home.html">E-Store</a>
 </header>
 <aside>
 <a href="cart.html">


    4 <img src="cart.jpg">
 </a>
 </aside>
 <main>
 <div>
 <input type="text">
 <button>search</button>
 </div>
 <div id="products">
 <ul>
 <li>
 <a href="product1.html">
 <h3>Product Title</h3>
 <img src="product.jpg">
 </a>
 </li> <li>...</li>
 </ul>
 </div>
 </main> appRoot my-store header search-bar products-list nav-bar product product product product x
  7. Component Template </> Controller { } Directive { } Component

    </> + { } Service { } Style {CSS} Hi Angular 2! <h1> Hi {{ name }}!
 </h1> name = 'Angular 2'; h1 { color: red }
  8. Component Template </> Controller { } Directive { } Component

    </> + { } Service { } Style {CSS} <h1> Hi {{ name }}!
 </h1> name = 'Angular 2'; h1 { color: red } Pipe { | } | uppercase
 Hi ANGULAR 2!
  9. appRoot my-store header search-bar products-list nav-bar product product product product

    x Inputs & Outputs <sj-product [product]="productToDisplay" (addToCart)="addProductToCart($event)"> </sj-product> ( output ) [ input ] <button (click)="..."> Add to Cart
 </button> <img [style.opacity]="...">
  10. More built-in directives ng-class [ngClass] ng-style [ngStyle] ng-switch *ngSwitch ng-switch-when

    *ngSwitchWhen ng-switch-default *ngSwitchDefault form form (QTOUCTGCYJQNG PQVJGTUWDLGEV
  11. appRoot my-store header search-bar products-list nav-bar product product product product

    x Change Detection product name changed using OnPush change detection strategy product list changed using immutable Objects
  12. appRoot my-store header search-bar products-list nav-bar product product product shopping

    cart service product x inject provide Services product service