subsystem-list.component.ts 877 Bytes
Newer Older
Vitali Stupin's avatar
Initial  
Vitali Stupin committed
1
2
3
4
5
import { Component, OnInit } from '@angular/core';
import { Subsystem } from '../subsystem';
import { MethodsService } from '../methods.service';

@Component({
6
7
8
  selector: 'app-subsystem-list',
  templateUrl: './subsystem-list.component.html',
  styleUrls: ['./subsystem-list.component.css']
Vitali Stupin's avatar
Initial  
Vitali Stupin committed
9
})
10
export class SubsystemListComponent implements OnInit {
Vitali Stupin's avatar
Initial  
Vitali Stupin committed
11
12
13
14
15
  subsystems: Subsystem[];

  constructor(private methodsService: MethodsService) { }

  ngOnInit() {
Vitali Stupin's avatar
Vitali Stupin committed
16
17
18
19
    // Service will tell when updated data is available!
    this.methodsService.subsystemsUpdated.subscribe(signal => {
      this.getMethods();
    });
Vitali Stupin's avatar
Vitali Stupin committed
20
21
22
    // If json data is loaded update event will not be emited.
    // This line must be after subscription (data may be changed while we start subscription)
    this.getMethods();
Vitali Stupin's avatar
Initial  
Vitali Stupin committed
23
24
25
  }

  getMethods(): void {
Vitali Stupin's avatar
Vitali Stupin committed
26
    this.subsystems = this.methodsService.getMethods();
Vitali Stupin's avatar
Initial  
Vitali Stupin committed
27
28
  }
}