だからこのエラーが発生し続ける "TypeError:プロパティ 'otherDocumentaryEvidence'未定義"を読み取ることができません "。私は何とかこのオブジェクトを初期化する必要があることを理解していますが、私はこれのプロセスを確信していません。私の理解では、オブジェクトが私のオブジェクトは、私が初期化私のコンポーネントのコードシェアケースオブジェクトとotherDocumentaryEvidenceオブジェクトの両方でこのOnInitで定義されているネストされたオブジェクトを初期化する方法は? Angular2
export class ShareCase {
shareCaseReason?: string;
caseDetails?: ICasedeit;
involvedPersonsAndOrganisations?: IInvolved;
policeOfficer?: IPolice;
incidents?: IIncident;
offences?: IOffence;
suspect?: ISuspectDetails
witnessStatements?: IStatements;
interviewNotes?: IIncident;
notebookEntries?: INotebook;
victims?: IVictim;
witnesses?: IWitness;
physicalEvidence?: IEvidence;
otherDocumentaryEvidence?: IDocEvidence;
}
のように見えるテンプレートサービス
ngOnInit(): void {
this._templateService
.getTemplateSnapshot(this.template)
.responseData()
.subscribe(templateSnapStream => {
return this.shareCase = templateSnapStream.result;
})
}
からngOnInit段階で定義されてしまうことですそのようなコンストラクタで:
this.shareCase = new ShareCase();
this.shareCase.otherDocumentaryEvidence = new IDocEvidence();
しかし、私はまだ同じエラーが発生しますか?なぜこれがわからないのですか?このオブジェクトを呼び出すテンプレートの行もこのようになります
<div *ngIf='shareCase && shareCase.case.otherDocumentaryEvidence && shareCase.case.otherDocumentaryEvidence.length > 0'>
ご協力いただけると助かります。
マジック!どうもありがとうございます! –
あなたをお手伝いします – Aravind