Angular 2 相当于 Ember.Computed('Prop1','Prop2'...'prop n')

Angular 2 equivalent of Ember.Computed('Prop1','Prop2'...'prop n')

我正在尝试将我的 Ember 应用程序移植到 Angular 2 , 但我没看到如何创建
Computed Properties--Properties observing other properties for changes and the reacting
在 Angular 2.

[(myVar)] &&  onMyVarChange= new EventMitter();

观察自身的变化和反应。

任何 help/directions 都会很棒。

更新:

使用@Nazim 的回答解决了它 使用的打字稿属性

TS (compoment.ts)

  private _isValid: boolean;
  public get isValid(): boolean {
    return this._isValid;
  }
  public set isValid(v: boolean) {
    this._isValid = v;
  }
  // A read only property
  private _show: boolean;
  public get show(): boolean {
    return this._isValid;
  }  

模板(component.html)

 <h2 *ngIf="show">Show Me</h2>

据我了解,Angular 2 使用原生 ES2015 计算属性。对于前。你可以定义一个 Person 组件:

export class PersonComponent {
  firstName: string;
  lastName: string;

  get fullName() {
    return `${this.firstName} ${this.lastName}`;
 }
} 

然后使用 ngModel 将 fullName 的值绑定到模板元素。