- Expert Angular
- Mathieu Nayrolles Rajesh Gunasundaram Sridhar Rao
- 175字
- 2021-07-15 17:05:28
Components
A component is a class that has properties and methods to be used in the view. These properties and methods exposed to view enable the view to interact with components. We code logic that supports the view in the component class:

For example, next is a component class book that has a properties title and author and a getPubName method that returns the name of the book:
export class BookComponent { title: string; author: string; constructor() { this.title = 'Learning Angular for .Net Developers'; this.author = 'Rajesh Gunasundaram'; } getPubName() : string { return 'Packt Publishing'; } }
Note: We will be using TypeScript in all our examples in this book.
The life cycle of a component is managed by Angular according to user interactions with the application. We can also add an event method that will be fired according to the state changes of the component. These event methods are known as life cycle hooks and are optional.
We will learn in detail about components in Chapter 5, Implementing Angular Routing and Navigation.
推薦閱讀
- Angular UI Development with PrimeNG
- WebAssembly實戰
- SpringMVC+MyBatis快速開發與項目實戰
- Python自動化運維快速入門
- 編寫整潔的Python代碼(第2版)
- ASP.NET 3.5程序設計與項目實踐
- Bootstrap 4:Responsive Web Design
- 快速念咒:MySQL入門指南與進階實戰
- Python算法指南:程序員經典算法分析與實現
- Keras深度學習實戰
- Kotlin極簡教程
- C編程技巧:117個問題解決方案示例
- Java從入門到精通(視頻實戰版)
- Visual Basic語言程序設計上機指導與練習(第3版)
- Unity與C++網絡游戲開發實戰:基于VR、AI與分布式架構