title: ERROR TypeError: _v.context.$implicit.toggle is not a function
body: <p>I am testing a simple recursive Treeview component in <strong>angular4</strong> using the below code. But whenever I try to expand the children view on <code>toggle()</code>. </p>
  
  <p>I am getting an exception error:</p>
  
  <blockquote>
    <p>ERROR TypeError: _v.context.$implicit.toggle is not a function</p>
  </blockquote>
  
  <p>Thanks</p>
  
  <p><strong>tree-view.component.ts</strong></p>
  
  <pre><code>export class TreeViewComponent implements OnInit {  
    constructor() { }
    ngOnInit() {}     
    @Input() directories: Directory[];
  }
  </code></pre>
  
  <p><strong>tree-view.component.html</strong></p>
  
  <pre><code>&lt;ul&gt;
    &lt;li *ngFor="let dir of directories"&gt;
      &lt;label (click)="dir.toggle()"&gt; {{ dir.title }}&lt;/label&gt;
      &lt;div *ngIf="dir.expanded"&gt;
        &lt;tree-view [locations]="dir.children"&gt;&lt;/tree-view&gt;
      &lt;/div&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Directory.ts</p>
  
  <pre><code> export class Directory{
  
        title: string;
        children: Directory[]
        expanded = true;
        checked = false;
  
    constructor() {
  
    }
  
    toggle() {
      this.expanded = !this.expanded;
    }
  
    getIcon() {
      if (this.expanded) {
        return '-';
      }
      return '+';
    }
  }
  </code></pre>