Angular 2 Ahead-of-Time compiler: must I make all class properties public?

后端 未结 2 1788
天命终不由人
天命终不由人 2020-12-03 03:20

Angular 2 rc 6, typescript 2, node 4.5.0, npm 2.15.9 on Windows 7

I\'m trying to move from Just-in-T

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 03:42

    So is too, in Final release of Angular 2 whit Ionic2 RC1

    A workaround for Fields could be to use getters without setters

    protected _myField: any;
    
    get myField(): any { 
      return this._myField; 
    }
    

    You can also see other JiT to AoT considerations to adapt your code in this blog of Isaac Mann

    1. const lambda => export function
    2. default export => named export
    3. private, protected accessors should be changed to public for any members accessed from template
    4. dynamic component template => static template
    5. moduleId should be set on components with templateUrl

提交回复
热议问题