官术网_书友最值得收藏!

Trade-offs

Since AOT is so advantageous, we recommend to use it in production. But, as with everything, there are trade-offs. For Angular to be able to compile your application ahead of time, the metadata has to be statically analyzable. For instance, the following code will not work in the AOT mode:

@Component({
selector: 'talk-cmp',
template: () => window.hide ? 'hidden' : `
{{talk.title}} {{talk.speaker}}
Rating: {{ talk.rating | formatRating }}
<watch-button [talk]="talk"></watch-button>
<rate-button [talk]="talk" (click)="onRate()"></rate-button>
`
})
class TalkCmp {
//...
}

The window.hide property will not be defined. So the compilation will fail to point out the error. A lot of work has been done to make the compiler smarter, so it can understand most of the day-to-day patterns you would use when building your application. But certain things will never work, like the preceding example.

主站蜘蛛池模板: 中阳县| 定结县| 江陵县| 平南县| 红桥区| 巴楚县| 攀枝花市| 台东县| 吉林省| 银川市| 五河县| 县级市| 房产| 读书| 大荔县| 天等县| 霍城县| 晋城| 咸阳市| 黎城县| 江西省| 瑞昌市| 清水河县| 江永县| 沅陵县| 泸西县| 汤原县| 呼伦贝尔市| 浑源县| 蒙阴县| 紫金县| 历史| 吉林省| 湘西| 晋江市| 潢川县| 庐江县| 合江县| 安乡县| 任丘市| 宣武区|