// 调用子组件 向子组件传值和方法的方式
<app-header [title]="title" [run]="run"></app-header>
在子组件中,引入Input,通过@input() 方式引入,即可通过this.xxx使用
import { Component, OnInit, Input } from '@angular/core'; @Component({ selector: 'app-header', templateUrl: './header.component.html', styleUrls: ['./header.component.less'] }) export class HeaderComponent implements OnInit { constructor() { } @Input() title: any; @Input() run: any; ngOnInit() { } getPatrent() { this.run(); } }