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

后端 未结 2 1797
天命终不由人
天命终不由人 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:54

    For a given component all its members (methods, properties) accessed by its template must be public in the ahead-of-time compilation scenario. This is due to the fact that a template is turned into a TS class. A generated class and a component are 2 separate classes now and you can't access private members cross-class.

    In short: you can't access private members in your templates if you want to use ahead-of-time compilation.

提交回复
热议问题