title: Angular 2 toggle class on click of list items. (Higlight the item in the list)
body: <p>I am trying to change the class once the item is clicked in the list , this is what i have tried to do this..</p>
  
  <pre><code>&lt;div class="groups"&gt;
      &lt;div class="group" *ngFor="#item of items | filter:queryElem.value:'title'"&gt;
          &lt;h5&gt;{{item.name}}&lt;/h5&gt;
          &lt;ul&gt;
              &lt;li *ngFor="#subItem of item.articles;#i = index"&gt;
                  &lt;span class="item toplevel" [ngClass]="{'selected': i === selectedIndex}"  href="#test" (click)="LoadArticleDetails(subItem.url,i);"&gt;{{subItem.title}}&lt;/span&gt;
                  &lt;ul&gt;
                      &lt;li *ngFor="#subarticle of subItem.children"&gt;
                             &lt;span class="item" href="#test" [ngClass]="{'selected': i === selectedIndex}" (click)="LoadArticleDetails(subarticle.url,i);"&gt;{{subarticle.title}}&lt;/span&gt;
                      &lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  
   export class TreeApp implements OnInit {
      selectedIndex = 0;
      LoadArticleDetails(url: string,index:any)
      {
          this.selectedIndex = index;
      }
   }
  </code></pre>