title: typescript, angular : unable to set value to class property, showing undefined property, while property is there
body: <p>I working in an Angular Application. I am really in stack situation.</p>
  <p><strong>InterviewStatusRecommendation</strong></p>
  <pre><code>export class InterviewStatusRecommendation {
      public recommendationRequest: RecommendationRequest;
      public recommendationInfoList: RecommendationInfo[];
  }
  </code></pre>
  <p><strong>RecommendationRequest</strong></p>
  <pre><code>export class RecommendationRequest {
      id: number;
      agentInitiationId: number;
      requestStatus: RecommendationRequestStatusEnum;
      accomplishDate: string;
      remarks: string;
  }
  </code></pre>
  <p><strong>RecommendationInfo</strong></p>
  <pre><code>export class RecommendationInfo {
      id: number;
      agentInitiationId: number;
      sequenceId: number;
      userName: string;
      assignDate: string;
      recommendStatus: InterviewAccomplishmentStatusEnum;
      remarks: string;
      recommendationDate: string;
      isRequired: boolean;
      isActive: boolean;
  }
  </code></pre>
  <p>Above is my three class. They are related to each other.
  I am trying to create an object of <code>InterviewStatusRecommendation</code> type and trying to set value to its property but it is showing error.</p>
  <p><strong>The code by which i am trying to set value.</strong></p>
  <pre><code>onSubmit (){
  
      const isRecommendation: InterviewStatusRecommendation = new InterviewStatusRecommendation();
              isRecommendation.recommendationRequest.agentInitiationId = this.agentInitiationId;
              isRecommendation.recommendationRequest.requestStatus = interviewStatus.interviewStatus;
              isRecommendation.recommendationRequest.remarks = interviewStatus.remarks;
              isRecommendation.recommendationRequest.accomplishDate = interviewStatus.invitationDate;
              interviewStatus.recommender.forEach(s =&gt; {
                  const info = new RecommendationInfo();
                  info.agentInitiationId = this.agentInitiationId;
                  info.userName = s;
                  isRecommendation.recommendationInfoList.push(info);
              });
  }
  </code></pre>
  <p><strong>Error Log.</strong></p>
  <pre><code>core.js:5980 ERROR TypeError: Cannot set property 'agentInitiationId' of undefined
      at RecommendationComponent.onSubmit (recommendation.component.ts:120)
      at RecommendationComponent_Template_form_ngSubmit_8_listener (recommendation.component.html:6)
      at executeListenerWithErrorHandling (core.js:14994)
      at wrapListenerIn_markDirtyAndPreventDefault (core.js:15029)
      at SafeSubscriber.schedulerFn [as _next] (core.js:25687)
      at SafeSubscriber.__tryOrUnsub (Subscriber.js:183)
      at SafeSubscriber.next (Subscriber.js:122)
      at Subscriber._next (Subscriber.js:72)
      at Subscriber.next (Subscriber.js:49)
      at EventEmitter_.next (Subject.js:39)
  </code></pre>
  <p>My question is <code>agentInitiationId</code> property is inside the class. Then why it is undefined?</p>