File

src/app/home/visualization.component.ts

import {
  Component,
  OnInit
} from '@angular/core';

import { Http, Response } from '@angular/http';
import { Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';

import {TimeNetDataService, TimeNetData, PersonData} from './timenet.service';
import {isNullOrUndefined} from "util";

export interface PersonSearchData {
  id: string,
  name: string,
  birth: number,
  dispName: string
}

@Component({
  // The selector is what angular internally uses
  // for `document.querySelectorAll(selector)` in our index.html
  // where, in this case, selector is the string 'home'
  selector: 'home',  // <home></home>
  // We need to tell Angular's Dependency Injection which providers are in our app.
  providers: [  ],
  // Our list of styles in our component. We may add more to compose many styles together
  styleUrls: [ './visualization.component.css' ],
  // Every Angular template is first compiled by the browser before Angular runs it's compiler
  templateUrl: './visualization.component.html',
})
export class VisualizationComponent implements OnInit {
    private chartData: Array<any>;

    private _timeNetData: TimeNetData;

  // TypeScript public modifiers
  constructor(
      public timeNetDataService: TimeNetDataService
  ) {}

  private personSearch: PersonSearchData[];

  public ngOnInit() {    // this.title.getData().subscribe(data => this.data = data);

    this._timeNetData = this.timeNetDataService.getTimeNetData();
    this.personSearch = this._timeNetData.persons.map((p) => <PersonSearchData>
      {id:p.id, name:p.name.join(' '), birth:p.dateOfBirth, dispName:p.name.join(' ')+' (' + p.dateOfBirth + ')'});
    this.selectedPerson = this._timeNetData.persons[Math.floor(Math.random() * this._timeNetData.persons.length)];

  }

  private selectedPerson: PersonData;

  public personSelected(person) {
    if(isNullOrUndefined(person) === false) {

        if(this.timeNetDataService.getPersonById(person.id))
          this.selectedPerson = this.timeNetDataService.getPersonById(person.id);

    }
  }

}

results matching ""

    No results matching ""