import { Component , Input , Output , EventEmitter } from '@angular/core' ; Input Output @ Component ( { selector : 'component-demo' , templateUrl : 'component-demo.html' } ) export class ComponentDemoComponent { @ Input ( 'fatherToSonData' ) fatherToSonData : string ; @ Output ( ) parentClick = new EventEmitter ( ) ; text : string ; constructor ( ) { this . text = 'Hello World' ; } sonClick ( ) { console . log ( 'son click' ) ; this . parentClick . emit ( { sonToFaterData : '我是子元素传递回去事件的参数' , } ) ; } }