- Essential Angular
- Victor Savkin Jeff Cross
- 132字
- 2021-07-02 22:56:26
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.
推薦閱讀
- Raspberry Pi for Python Programmers Cookbook(Second Edition)
- 跟“龍哥”學C語言編程
- AngularJS Web Application Development Blueprints
- 實用防銹油配方與制備200例
- Visual C
- Oracle Exadata專家手冊
- Hands-On Nuxt.js Web Development
- 鴻蒙OS應用編程實戰
- C++ Fundamentals
- 零基礎輕松學C++:青少年趣味編程(全彩版)
- JavaScript編程精解(原書第2版)
- Python編程快速上手2
- Monitoring Docker
- 程序員面試金典(第6版)
- Mastering Data Analysis with R