angular8 earth teacher study notes --- Lesson Nine

Parent component: News Component

<App-header [title] = "title" [MSG] = "MSG" [RUN] = 'RUN' [Home] = 'the this'> </ App-header> 

<div> I Home component </ div>

 

Subcomponents: header assembly

{the Component Import, the OnInit, from the Input} '@ Angular / Core'; 

@Component ({
Selector: 'App-header',
templateUrl: './header.component.html',
styleUrls: [ './header.component. SCSS ']
})
Export class HeaderComponent the implements the OnInit {

// receiving data from the parent component
@input () title: the any;

@input () MSG: the any;

@input () RUN: the any;

@input () Home: the any;

constructor () {}

ngOnInit () {}

getParentMsg () {
// get the data parent element
Alert (this.msg);
}

getParentRun () {
// RUN method performed parent element
// this.run () ;
Alert (this.home.msg);
this.home.run ();
}

}

 

 

 

 

 





Guess you like

Origin www.cnblogs.com/fpcing/p/11991771.html