1、子组件
//.ts
export class ContentComponent implements OnInit {
public msg:string = "我是子组件"
constructor() { }
ngOnInit() {
}
}
2、父组件
//父组件
.html
<app-content #content></app-content>
<p>{{content.msg}}</p>
//.ts
import { Component, ViewChild } from '@angular/core';
...
export class AppComponent {
title = 'my-ng-app02';
@ViewChild('content',{static:false}) content:any
}