SHARE
TWEET

Untitled

a guest Jan 18th, 2016 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {Component} from 'angular2/core';
  2. import {Hero} from './hero';
  3. import {HeroDetailComponent} from './hero-detail.component';
  4.  
  5. @Component({
  6.     selector: 'my-app',
  7.     template: `
  8.     <h1>{{title}}</h1>
  9.    
  10.     <h2>My Heroes</h2>
  11.     <ul class='heroes'>
  12.         <li *ngFor="#hero of heroes" [class.selected]="hero === selectedHero" (click)="onSelect(hero)">
  13.             <span class="badge">{{hero.id}}</span> {{hero.name}}
  14.         </li>
  15.     </ul>
  16.    
  17.     <my-hero-detail [hero]="selectedHero"></my-hero-detail>`,
  18.     styles: [`
  19.         .selected {
  20.             background-color: #CFD8DC !important;
  21.             color: white;
  22.         }
  23.         .heroes {
  24.             margin: 0 0 2em 0;
  25.             list-style-type: none;
  26.             padding: 0;
  27.             width: 10em;
  28.         }
  29.         .heroes li {
  30.             cursor: pointer;
  31.             position: relative;
  32.             left: 0;
  33.             background-color: #EEE;
  34.             margin: 0.5em;
  35.             padding: 0.3em 0em;
  36.             height: 1.6em;
  37.             border-radius: 4px;
  38.         }
  39.         .heroes li.selected:hover {
  40.             color:white;
  41.         }
  42.         .heroes li:hover {
  43.             color: #607D8B;
  44.             background-color: #EEE;
  45.             left: .1em;
  46.         }
  47.         .heroes .text {
  48.             position:relative;
  49.             top: -3px;
  50.         }
  51.         .heroes .badge {
  52.             display; inline-block;
  53.             font-size: small;
  54.             color: white;
  55.             padding: 0.8em 0.7em 0em 0.7em;
  56.             background-color: #607D8B;
  57.             line-height: 1em;
  58.             position: relative;
  59.             left: -1px;
  60.             top: -4px;
  61.             height: 1.8em;
  62.             margin-right: 0.8em;
  63.             border-radius: 4px 0px, opx, 4px;
  64.         }
  65.     `],
  66.     directives: [HeroDetailComponent]
  67. })
  68.  
  69. export class AppComponent {
  70.     public title = 'Tour of Heroes';
  71.     public heroes = HEROES;
  72.     public selectedHero: Hero;
  73.    
  74.     onSelect(hero: Hero) { this.selectedHero = hero; }
  75.  }
  76.  
  77.  var HEROES: Hero[] = [
  78.      {"id": 11, "name": "Mr. Nice"},
  79.      {"id": 12, "name": "Narco"},
  80.      {"id": 13, "name": "Bombasto"},
  81.      {"id": 14, "name": "Celeritas"},
  82.      {"id": 15, "name": "Magneta"},
  83.      {"id": 16, "name": "RubberMan"},
  84.      {"id": 17, "name": "Dynama"},
  85.      {"id": 18, "name": "Dr IQ"},
  86.      {"id": 19, "name": "Magma"},
  87.      {"id": 20, "name": "Tornado"},
  88.  ]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top