title: how to get value from angular 4 observable response?
body: <p>my issue is that data i am getting is in observable so i check if data is 
  undefined and when it is not undefined i put it into doctor object but 
  some of my code use the data before it populate and generate error because 
  value is undefined how can i get the value of response in a variable .       </p>
  
  <pre><code>    workingDayFilter = ( d: Date ): boolean =&gt; {
      const day = d.getDay();
      let workingDays = this.doctor.workingDays;
      let result: boolean = false;
  
      for ( let i = 0; i &lt; workingDays.length; i++ ) {
          if ( day == workingDays[i] ) {
              result = true;
          }
      }
  
      return result;
  
  }
  
  
  ngOnInit() {
  
      this.getDoctor();
  
  
      console.log( this.doctor );
      this.appointmentForm = this.formBuilder.group( {
          patientId: this.patientId,
          date: this.date,
          timeSlot: this.timeSlot
      } );
  
  }
  public getDoctor() {
      this.doctorService.getDoctorPublicInfo().subscribe(( data ) =&gt; {
          if ( data != undefined ) {
              this.doctor = data.json();
          }
      } );
  }
  </code></pre>