title: how to access object properties from TypeScript?
body: <p>I'm new to Angular and TypeScript and just started working on a project using MEAN stack (MongoDB, Express, Angular, Node.js).</p>
  
  <p>I created this mongoose module :</p>
  
  <pre><code>import * as mongoose from 'mongoose';
  
  var Schema = mongoose.Schema;
  const entrepriseSchema = new mongoose.Schema({
    name: {type: String, unique: true, required : true},
    telephone: Number,
    logo: String,
    web_site: String,
    sites: [
      {site_id: {type: Schema.Types.ObjectId, ref: 'Site'}}
    ]
  });
  
  const Entreprise = mongoose.model('Entreprise', entrepriseSchema);
  
  export default Entreprise;
  </code></pre>
  
  <p>and this is my entreprise.component.ts :</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { Http } from '@angular/http';
  import { FormGroup, FormControl, Validators, FormBuilder } from '@angular/forms';
  import { ActivatedRoute } from '@angular/router';
  
  import { EntrepriseService } from '../services/entreprise.service';
  import { SiteService } from '../services/site.service';
  
  
  @Component({
    selector: 'app-entreprise',
    templateUrl: './entreprise.component.html',
    styleUrls: ['./entreprise.component.scss'],
    providers: [EntrepriseService, SiteService]
  })
  export class EntrepriseComponent implements OnInit {
  
  
    entreprise = {};
    sites = [];
    id: String;
  
    constructor(private entrepriseService: EntrepriseService,
                private siteService: SiteService,
                private http: Http,
                private route: ActivatedRoute) {
      this.id = route.snapshot.params['id'];
    }
  
    ngOnInit() {
      this.getEntrepriseById(this.id);
      //not working
      //console.log(this.entreprise.name);
      //console.log(this.entreprise.sites);
      //this.getSitesIn(this.entreprise.sites);
    }
  
    getEntrepriseById(id) {
      this.entrepriseService.getEntreprise(id).subscribe(
        data =&gt; this.entreprise = data,
        error =&gt; console.log(error)
      );
    }
  
    getSitesIn(ids) {
      this.siteService.getSitesIn(ids).subscribe(
        data =&gt; this.sites = data,
        error =&gt; console.log(error)
      );
    }
  }
  </code></pre>
  
  <p>when I try to display the properties of the returned from entreprise.component.html it works fine and displays all the properties : </p>
  
  <pre><code>  &lt;h3&gt;{{entreprise.name}}&lt;/h3&gt;
         &lt;div *ngFor="let site of entreprise.sites"&gt;
           {{site.site_id}}
         &lt;/div&gt;
           {{entreprise.logo}}
           {{entreprise.web_site}}
  </code></pre>
  
  <p>but how can I access the same properties on the TypeScript side ? 
  The commented code in the EntrepriseComponent is what I'm trying to accomplish but it's not working since <code>this.entreprise</code> is type {} .</p>