Angular 角度值到达子组件模板,但在ngOnInit中未定义

Angular 角度值到达子组件模板,但在ngOnInit中未定义,angular,angular-components,ngoninit,Angular,Angular Components,Ngoninit,当我将值传递给子组件时,值将出现在模板中,但不会显示在子组件的ngOnInit中 父组件 <div class="overview bg-blue-pattern">prospectId {{prospectId}} <app-calls-log-history [prospectid]="prospectId"></app-calls-log-history> </div> prospectId{{prospectId}

当我将值传递给子组件时,值将出现在模板中,但不会显示在子组件的ngOnInit中

父组件

<div class="overview bg-blue-pattern">prospectId {{prospectId}}
        <app-calls-log-history [prospectid]="prospectId"></app-calls-log-history>
    </div>
prospectId{{prospectId}
童装

<div class="calls-log-history-container">
        prospectId {{prospectid}}
    </div>

prospectId{{prospectId}}
子组件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;
        }
    );
  }
}
从'@angular/core'导入{Component,OnInit,Input};
从“../../../../services/contact.service”导入{ContactFilterService};
@组成部分({
选择器:“应用程序调用日志历史记录”,
templateUrl:'./调用log history.component.html',
styleUrls:['./调用日志历史记录.component.scss']
})
导出类CallsLogHistoryComponent实现OnInit{
@Input()prospectid:any;
CallsLogHistory:Array=[];
构造函数(私有_contactFilterService:contactFilterService){}
恩戈尼尼特(){
console.log('prospectid:'+this.prospectid);//未定义
此.\u contactFilterService.getCallsLogHistory(this.prospectid).订阅(
结果=>{
this.CallsLogHistory=result.notes;
}
);
}
}

简短回答,使用
*ngIf

<div class="overview bg-blue-pattern" *ngIf="prospectId">prospectId {{prospectId}}
    <app-calls-log-history [prospectid]="prospectId"></app-calls-log-history>
</div>
prospectId{{prospectId}

简短回答,使用
*ngIf

<div class="overview bg-blue-pattern" *ngIf="prospectId">prospectId {{prospectId}}
    <app-calls-log-history [prospectid]="prospectId"></app-calls-log-history>
</div>
prospectId{{prospectId}