- 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.
推薦閱讀
- Reporting with Visual Studio and Crystal Reports
- Practical Internet of Things Security
- Java Web開發(fā)之道
- Learn Scala Programming
- Learning DHTMLX Suite UI
- Hands-On Nuxt.js Web Development
- Learning Node.js for .NET Developers
- QGIS Python Programming Cookbook(Second Edition)
- C++ Fundamentals
- Bootstrap for Rails
- 零基礎(chǔ)輕松學(xué)C++:青少年趣味編程(全彩版)
- Java Web開發(fā)基礎(chǔ)與案例教程
- JavaWeb從入門到精通(視頻實(shí)戰(zhàn)版)
- Learning C# by Developing Games with Unity 3D Beginner's Guide
- Prezi Cookbook