ngClass is not working like it should

Viewed 2675

I'm playing around with ngClass, and I do not know what I am doing wrong. It is showing weird behavior. It seems like when I assign a function to ngClass it does not work, but if I assign it an object literal it works. How can I get ngClass to work with my Component's function?

ProposalForm.ts

import {Component} from 'angular2/core';
import {NgClass}    from 'angular2/common';
@Component({
  selector: 'proposal-form',
  template: `
   <div [ngClass]="setClasses()">
    ghtfhg
  </div>
  <div [ngClass]="{active:true, disabled:true}">
    1111111
  </div>`,
  directives:[NgClass]
})
export class ProposalForm {

  setClasses() {
   return {active:true, disabled:true};
  }
}

Looking at Chrome's Inspector this is the HTML

<proposal-form _ngcontent-xxb-2="">
<div class="">
  ghtfhg
</div>
<div class="active disabled">
  1111111
</div></proposal-form>
2 Answers
Related