父組件中定義: public detailbaseinfo = {}; //詳情基本信息
其中detailbaseinfo 數據會通過請求獲取
父組件傳值給子組件如下:

子組件接收父組件傳值
import { Component, Inject, OnInit, OnChanges, SimpleChange , Input, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'app-introduce',
templateUrl: './introduce.page.html',
styleUrls: ['./introduce.page.scss'],
})
export class IntroducePage implements OnChanges {
@Input() detailbaseinfo: any; //接收課程信息
constructor(@Inject('urlConfig')private urlConfig) { }
ionViewWillEnter() {
}
ngOnChanges(changes:{[propKey:string]: SimpleChange }) {
this.detailbaseinfo = changes['detailbaseinfo']['currentValue'];
console.log(this.detailbaseinfo)
}
}
detailbaseinfo 在請求完成之前傳給子組件的值為{},那么不符合實際需求,則需用到ngOnChanges去監聽,當父組件中請求完成,detailbaseinfo 會被賦值,此刻才滿足需求
