<html>
  <head>
    <title>Tour of Heroes</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="style.css">

    <!-- 1. Load libraries -->
    <!-- IE required polyfill -->
    <script src="https://code.angularjs.org/2.0.0-beta.8/angular2-polyfills.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.8/Rx.umd.min.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.8/angular2-all.umd.dev.js"></script>
    <!-- 2. Load our 'modules' -->
    <script src='app/app.component.js'></script>
    <script src='app/main.js'></script>

  </head>

  <!-- 3. Display the application -->
  <body>
    <my-app>Loading...</my-app>
  </body>

</html>
/* Master Styles */
h1 {
  color: #369; 
  font-family: Arial, Helvetica, sans-serif;   
  font-size: 250%;
}
h2, h3 { 
  color: #444;
  font-family: Arial, Helvetica, sans-serif;   
  font-weight: lighter;
}
body { 
  margin: 2em; 
}
body, input[text], button { 
  color: #888; 
  font-family: Cambria, Georgia; 
}
a {
  cursor: pointer;
  cursor: hand;
}
button {
  font-family: Arial;
  background-color: #eee;
  border: none;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  cursor: hand;
}
button:hover {
  background-color: #cfd8dc;
}
button:disabled {
  background-color: #eee;
  color: #aaa; 
  cursor: auto;
}

/* Navigation link styles */
nav a {
  padding: 5px 10px;
  text-decoration: none;
  margin-top: 10px;
  display: inline-block;
  background-color: #eee;
  border-radius: 4px;
}
nav a:visited, a:link {
  color: #607D8B;
}
nav a:hover {
  color: #039be5;
  background-color: #CFD8DC;
}
nav a.router-link-active {
  color: #039be5;
}

/* items class */
.items {
  margin: 0 0 2em 0;
  list-style-type: none;
  padding: 0;
  width: 24em;
}
.items li {
  cursor: pointer;
  position: relative;
  left: 0;
  background-color: #EEE;
  margin: .5em;
  padding: .3em 0;
  height: 1.6em;
  border-radius: 4px;
}
.items li:hover {
  color: #607D8B;
  background-color: #DDD;
  left: .1em;
}
.items li.selected:hover {
  background-color: #BBD8DC;
  color: white;
}
.items .text {
  position: relative;
  top: -3px;
}
.items {
  margin: 0 0 2em 0;
  list-style-type: none;
  padding: 0;
  width: 24em;
}
.items li {
  cursor: pointer;
  position: relative;
  left: 0;
  background-color: #EEE;
  margin: .5em;
  padding: .3em 0;
  height: 1.6em;
  border-radius: 4px;
}
.items li:hover {
  color: #607D8B;
  background-color: #DDD;
  left: .1em;
}
.items li.selected {
  background-color: #CFD8DC;
  color: white;
}

.items li.selected:hover {
  background-color: #BBD8DC;
}
.items .text {
  position: relative;
  top: -3px;
}
.items .badge {
  display: inline-block;
  font-size: small;
  color: white;
  padding: 0.8em 0.7em 0 0.7em;
  background-color: #607D8B;
  line-height: 1em;
  position: relative;
  left: -1px;
  top: -4px;
  height: 1.8em;
  margin-right: .8em;
  border-radius: 4px 0 0 4px;
}

/* everywhere else */
* { 
  font-family: Arial, Helvetica, sans-serif; 
}


/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/
# Tour of Heroes
## 3. Master/Detail
Implementation of [Angular 2 tutorial](https://angular.io/docs/ts/latest/tutorial/toh-pt2.html) in javascript

[On my GitHub](https://github.com/maxim-yakupov/maxim-yakupov.github.io/tree/a912f691f3d19d823c96f1fc9c38a67d968f39f1/angular2-quickstart)
(function(app) {
  document.addEventListener('DOMContentLoaded', function() {
    ng.platform.browser.bootstrap(app.AppComponent);
  });
})(window.app || (window.app = {}));
(function(app) {
  /* global ng */
  function Hero(id, name) {
    this.id = id;
    this.name = name;
  }

  app.AppComponent =
    ng.core.Component({
      "selector" : 'my-app',
      "template" : `
                <h1>{{title}}</h1>
                <h2>My Heroes</h2>
                <ul class="heroes">
                  <li *ngFor="#hero of heroes"
                    [class.selected]="hero === selectedHero"
                    (click)="onSelect(hero)">
                    <span class="badge">{{hero.id}}</span> {{hero.name}}
                  </li>
                </ul>
                <div *ngIf="selectedHero">
                  <h2>{{selectedHero.name}} details!</h2>
                  <div><label>id: </label>{{selectedHero.id}}</div>
                  <div>
                    <label>name: </label>
                    <input [(ngModel)]="selectedHero.name" placeholder="name"/>
                  </div>
                </div>
                `,
      "styles" : [`
                .selected {
                  background-color: #CFD8DC !important;
                  color: white;
                }
                .heroes {
                  margin: 0 0 2em 0;
                  list-style-type: none;
                  padding: 0;
                  width: 10em;
                }
                .heroes li {
                  cursor: pointer;
                  position: relative;
                  left: 0;
                  background-color: #EEE;
                  margin: .5em;
                  padding: .3em 0;
                  height: 1.6em;
                  border-radius: 4px;
                }
                .heroes li.selected:hover {
                  background-color: #BBD8DC !important;
                  color: white;
                }
                .heroes li:hover {
                  color: #607D8B;
                  background-color: #DDD;
                  left: .1em;
                }
                .heroes .text {
                  position: relative;
                  top: -3px;
                }
                .heroes .badge {
                  display: inline-block;
                  font-size: small;
                  color: white;
                  padding: 0.8em 0.7em 0 0.7em;
                  background-color: #607D8B;
                  line-height: 1em;
                  position: relative;
                  left: -1px;
                  top: -4px;
                  height: 1.8em;
                  margin-right: .8em;
                  border-radius: 4px 0 0 4px;
                }
              `]
    })
    .Class({
      constructor: function() {
      	this.title = 'Tour of Heroes';
      	this.selectedHero = null;
      	this.heroes = [
                { "id": 11, "name": "Mr. Nice" },
                { "id": 12, "name": "Narco" },
                { "id": 13, "name": "Bombasto" },
                { "id": 14, "name": "Celeritas" },
                { "id": 15, "name": "Magneta" },
                { "id": 16, "name": "RubberMan" },
                { "id": 17, "name": "Dynama" },
                { "id": 18, "name": "Dr IQ" },
                { "id": 19, "name": "Magma" },
                { "id": 20, "name": "Tornado" }
              ];
        this.onSelect = function(hero) {
          this.selectedHero = hero;
        };
	    }
    });
})(window.app || (window.app = {}));