1. //1.子组件自定义属性接收父组件传递过来的参数
    2. <app-MovieItem [title]="title"></app-MovieItem>
    1. // 2.在子组件中用@Input注册
    2. import { Component, OnInit,Input } from '@angular/core';
    3. @Component({
    4. selector: 'app-MovieItem',
    5. templateUrl: './MovieItem.component.html',
    6. styleUrls: ['./MovieItem.component.css']
    7. })
    8. export class MovieItemComponent implements OnInit {
    9. constructor() { }
    10. @Input() title!:String;
    11. ngOnInit() {
    12. }
    13. }
    1. // 3.使用
    2. <p>{{title}}</p>