逻辑过程
在初始化ngrx之后,就要考虑如何使用,事件的场景是点击歌单之后会播放歌曲,所以要声明一个播放事件。
- home.component.html
<!--热门歌单开始-->
<div class="down">
<div class="down-wrap">
<app-single-sheet
class="sheet-item"
*ngFor="let item of songSheetList"
[sheet]="item"
(onPlay)="onPlaySheet($event)"
></app-single-sheet>
</div>
</div>
<!--热门歌单结束-->
在点击之后,触发onPlaySheet()事件
- home.component.ts
constructor(
private route: ActivatedRoute,
private sheetServe: SheetService,
private store$: Store<AppStoreModule>,
) {
this.route.data.pipe(map(res => res.homeDatas)).subscribe(([banners, hotTags, songSheetList, singers]) => {
this.banners = banners;
this.hotTags = hotTags;
this.