Answer the question
In order to leave comments, you need to log in
How to pass parameter from service to component?
There is a service.
I pass an array of songs into it, at the end they change ({title:string, file:string}).
How can I pass to another component that the song has changed and its name?
Angular 2
Answer the question
In order to leave comments, you need to log in
Look at https://makeomatic.ru/blog/2014/10/07/Angular_scop...
In the component class, you declare variables and track (subscribe) the change in the array with songs, something like this:
playing: string; //в рендере *ngFor="let track of tracks", например, {{track.playing}}
title: string; //в рендере *ngFor="let track of tracks", например, {{track.title}}
ngOnInit(){
this.songsService.getSongs().subscribe(
(data) => this.myTracks = data
);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question