1.子组件自定义属性接收父组件传递过来的参数
//1.子组件自定义属性接收父组件传递过来的参数//app.component.html<app-MovieItem [title]="title"></app-MovieItem>
2.在子组件中使用@Input进行注册
//2.在子组件中使用@Input进行注册//MovieItem.component.tsimport { Component, OnInit,Input } from '@angular/core';export class MovieItemComponent implements OnInit { @Input() title!: String; //@Input() music!:any}
3.在子组件的模板中直接使用
//3.在子组件的模板中直接使用//MovieItem.component.html<div class="item" *ngFor="let item of music"> <img src="{{item.coverImgUrl}}" alt="" class="img"> <p class="title">{{item.name}}</p> <div class="play">{{item.playCount}}</div></div>