songlist click causes routing

This commit is contained in:
2019-11-24 16:18:57 +01:00
committed by smuddy
parent d3f8cca4b1
commit 0bfee780e8
7 changed files with 19 additions and 9 deletions

View File

@@ -1,6 +1,8 @@
import {Component, OnInit} from '@angular/core';
import {SongService} from '../services/song.service';
import {Song} from '../models/song';
import {map} from 'rxjs/operators';
import {Observable} from 'rxjs';
@Component({
selector: 'app-songs',
@@ -8,15 +10,15 @@ import {Song} from '../models/song';
styleUrls: ['./song-list.component.less']
})
export class SongListComponent implements OnInit {
public songs: Song[];
public songs: Observable<Song[]>;
constructor(private songService: SongService) {
}
ngOnInit() {
this.songService.list().subscribe(songs => {
this.songs = songs.sort((a, b) => a.number - b.number);
});
this.songs = this.songService.list().pipe(map(songs =>
songs.sort((a, b) => a.number - b.number)
));
}
}