<commit_before>import {Component, View} from 'angular2/angular2';
import {Router} from 'angular2/router';
import {HeroService} from './hero.service';
import {Hero} from './hero';
import {Routes} from './route.config';
import {COMMON_DIRECTIVES} from './constants';

@Component({ selector: 'my-heroes' })
@View({
  templateUrl: 'app/heroes.component.html',
  directives: [COMMON_DIRECTIVES],
  styleUrls: ['app/heroes.component.css']
})
export class HeroesComponent {
  private _heroes: Hero[];
  public currentHero: Hero;

  constructor(private _heroService: HeroService, private _router: Router) { }

  get heroes() { return this._heroes || this.getHeroes(); }

  getHeroes() {
    this.currentHero = undefined;
    this._heroes = [];
    this._heroService.getHeroes()
      .then(heroes => this._heroes = heroes);

    return this._heroes;
  }

  getSelectedClass(hero: Hero) {
    return { 'selected': hero === this.currentHero };
  }

  goDetail() {
    this._router.navigate(`${Routes.detail.as}/${this.currentHero.id}`);
  }

  onSelect(hero: Hero) { this.currentHero = hero; }
}<commit_msg>Implemented OnInit to get the heroes list instead of a bound property<commit_after>import {Component, OnInit, View} from 'angular2/angular2';
import {Router} from 'angular2/router';
import {HeroService} from './hero.service';
import {Hero} from './hero';
import {Routes} from './route.config';
import {COMMON_DIRECTIVES} from './constants';

@Component({ selector: 'my-heroes' })
@View({
  templateUrl: 'app/heroes.component.html',
  directives: [COMMON_DIRECTIVES],
  styleUrls: ['app/heroes.component.css']
})
export class HeroesComponent implements OnInit {
  heroes: Hero[];
  currentHero: Hero;

  constructor(private _heroService: HeroService, private _router: Router) { }

  onInit() {
    this.heroes = this.getHeroes();
  }

  getHeroes() {
    this.currentHero = undefined;
    this.heroes = [];

    this._heroService.getHeroes()
      .then(heroes => this.heroes = heroes);

    return this.heroes;
  }

  getSelectedClass(hero: Hero) {
    return { 'selected': hero === this.currentHero };
  }

  goDetail() {
    this._router.navigate(`${Routes.detail.as}/${this.currentHero.id}`);
  }

  onSelect(hero: Hero) { this.currentHero = hero; }
}
{'fraction_non_alphanumeric': 0.15637494446912484, 'fraction_numerical': 0.0026654820079964462, 'mean_word_length': 4.261682242990654, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3715723', 'n_tokens_mistral': 760, 'n_tokens_neox': 748, 'n_words': 164}