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

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.

主站蜘蛛池模板: 长治市| 玛纳斯县| 丰都县| 夏邑县| 阳泉市| 新建县| 兰州市| 包头市| 天长市| 东阿县| 永寿县| 内丘县| 榆树市| 江西省| 虹口区| 得荣县| 琼结县| 延川县| 白河县| 云龙县| 南开区| 五家渠市| 岢岚县| 南投市| 南宁市| 哈巴河县| 昌宁县| 陆良县| 津南区| 邵东县| 建德市| 兰州市| 宁津县| 涞水县| 宣汉县| 丽水市| 合水县| 双峰县| 高阳县| 莱阳市| 靖远县|