Issue
I have a few named router outlets in an angular app:
<router-outlet name="song"></router-outlet>
<router-outlet name="songDetails"></router-outlet>
<router-outlet name="songLyrics"></router-outlet>
each of these panes displays information about the song... the player, the metadata, and the lyrics. Is there a way to use the "song id" (from my database) for all three of these without having to have a route like this:
/music/(song:1234//songDetails:1234//songLyrics:1234)
The "issue" is repeating the id between all three routes. Can I share this and still access it from all the controllers?
Solution
A Shared Service is the way to go. Having a simple service cache the current id and imported by the component modules takes care of this.
CachedSongService {
currentId;
}
You can even make getters and setters to protect the ID from being overwritten by specific components.
Answered By - Jeff
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.