Hi I am trying to create a simple grid with sorting feature using Angular 2. Below is the structure of the component.
import {Component, Pipe} from 'angular2/core';
import {NgClass} from 'angular2/common';
@Component({
selector: "sorter",
template: `
<i class="indicator glyphicon glyphicon glyphicon-sort-by-alphabet" [ngClass]="{'glyphicon-sort-by-alphabet-alt': isReverse}"></i>
<span>{{isReverse}}</span>
`,
directives: [NgClass]
})
export class Sorter {
isReverse = true;
public sortData(key) {
this.isReverse = !this.isReverse;
console.log("Directection-->" + this.isReverse);
}
}
I have created a var isReverse and changing it in the the sortData() method. The console.log() prints the correct value when I click the column header but it is not affecting the template. I am unable to figure what is going wrong here.
Thanks