当我将值传递给模板中的子组件值但未显示在子组件的 ngOnInit 中时
父组件
<div class="overview bg-blue-pattern">prospectId {{prospectId}}
<app-calls-log-history [prospectid]="prospectId"></app-calls-log-history>
</div>
子组件
<div class="calls-log-history-container">
prospectId {{prospectid}}
</div>
子组件ts文件
import { Component, OnInit,Input } from '@angular/core';
import { ContactFilterService } from '../../../../services/contact.service';
@Component({
selector: 'app-calls-log-history',
templateUrl: './calls-log-history.component.html',
styleUrls: ['./calls-log-history.component.scss']
})
export class CallsLogHistoryComponent implements OnInit {
@Input() prospectid: any;
CallsLogHistory: Array<any> = [];
constructor( private _contactFilterService: ContactFilterService) { }
ngOnInit() {
console.log('prospectid : '+ this.prospectid); // coming as undefined
this._contactFilterService.getCallsLogHistory(this.prospectid).subscribe(
result => {
this.CallsLogHistory = result.notes;
}
);
}
}