- 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.
推薦閱讀
- OpenStack Cloud Computing Cookbook(Third Edition)
- Instant Node Package Manager
- Mastering phpMyAdmin 3.4 for Effective MySQL Management
- Getting Started with SQL Server 2012 Cube Development
- 零基礎學Java程序設計
- Learning Selenium Testing Tools(Third Edition)
- Python之光:Python編程入門與實戰
- OpenResty完全開發指南:構建百萬級別并發的Web應用
- HoloLens與混合現實開發
- HTML5程序設計基礎教程
- 現代JavaScript編程:經典范例與實踐技巧
- PHP程序設計經典300例
- Java語言GUI程序設計
- Learning Java by Building Android Games
- 零基礎學Java(升級版)