list-vessel.component.ts
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import {Component, OnInit} from '@angular/core';
import {VesselsService} from '../../service/vessels.service';
import {Vessels} from '../../model/vessels';
import {Vessel} from '../../model/vessel';
import {SelectedVesselService} from '../../service/selected-vessel.service';
declare var $: any;
@Component({
selector: 'app-list-vessel',
templateUrl: './list-vessel.component.html',
styleUrls: ['./list-vessel.component.scss']
})
export class ListVesselComponent implements OnInit {
vessels: Vessels;
selectedVessel: Vessel;
constructor(private vesselsService: VesselsService, private selectedVesselService: SelectedVesselService) {
}
ngOnInit(): void {
this.vesselsService.currentVessels.subscribe(vessels => {
setTimeout(() =>
this.vessels = vessels
);
});
this.selectedVesselService.currentVessel.subscribe(selectedVessel => {
this.selectedVessel = selectedVessel;
});
$(document).ready(() => {
$('#myInput').on('keyup', function(): void {
const value = $(this).val().toLowerCase();
$('#list-tab a').filter(function(): void {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1);
});
});
});
}
onSelectVessel(vessel: Vessel): void {
this.selectedVesselService.changeVesselSet(vessel);
}
}