从类更改组件装饰器Angular 2的属性

时间:2016-08-13 11:56:58

标签: angular typescript components

我希望在某些操作发生后更改模板

@Component({
  ... 
  template: this.myTemplate
})

export class App {
  myTemplate: = 'Here is first template';

  // Replace templates
  public changeTempate() {
    myTemplate = 'Here is second template';
  }

如何使此代码有效?

1 个答案:

答案 0 :(得分:0)

最后它是在Angular 2.3.0中制作的 这是一个简单的例子:

Home

欲了解更多信息,请阅读

  

https://medium.com/@gerard.sans/angular-2-new-features-in-angular-2-3-f2e73f16a09e#.33fk3molt

相关问题