title: Cannot convert undefined or null to object Angular
body: <p>I try to make a filter method this method works well but I have an error: <code>cannot convert undefined or null to object that I cannot solve</code></p>
  <p><strong>example json</strong></p>
  <pre><code>{
    &quot;toto&quot;: [
      &quot;titi&quot;,
      &quot;tata&quot;
    ],
    hideString: [], // filter method hide this element
  &quot;foo&quot;: [
      &quot;foobar&quot;,
      &quot;footix&quot;
    ]
  </code></pre>
  <p>}</p>
  <p><strong>card.components.ts</strong></p>
  <pre><code>    @Input() toto: ISummary[] = []
      
      getKeys() {
       Object.keys(this.toto).filter(key =&gt; this.toto[key].lenght &gt; 0)
       // in my console I have the following error: cannot convert undefined or null to object 
          the error comes from this line
      }
      
      totoa(keys:string){
       return this.toto[key]
      }
  </code></pre>
  <p><strong>card.html</strong></p>
  <pre><code>&lt;div *ngFor=&quot;let keys of getKeys()&quot;&gt;
   {{keys}}
    &lt;div *ngFor=&quot;let values of totoa(keys)&quot;&gt;
      {{values}}
    &lt;/div
  &lt;/div
  </code></pre>
  <p><strong>home.components.ts</strong></p>
  <pre><code>public result: string = '';
  
  public toto?: Observable&lt;ISummary[]&gt;; // maybe the problem comes from Here I have ternary operator '?'
  
  
  ngOnInit() {
   this.activatedRoute.paramMap.subscribe(params = &gt; {
    let bigramme = params.get('bigramme');
    this.result = bigramme as string;
    getSummary();
   }
  }
  
  getSummary() {
   this.toto = this.sumService.getAllSummary(this.result);
  }
  </code></pre>