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

Components and Directives

To build an Angular application you define a set of components, for every UI element, screen, and route. An application will always have root components (usually just one) that contain all other components. To make things simpler, in this book let's assume the application has a single root component, and thus our Angular application will have a component tree, that may look like this:

AppCmp is the root component. The FiltersCmp component has the speaker input and the filter button. TalksCmp is the list you see at the bottom. And TalkCmp is an item in that list. To understand what constitutes a component in Angular, let's look closer at TalkCmp:

@Component({
selector: 'talk-cmp',
template: `
{{talk.title}} {{talk.speaker}}
{{talk.rating | formatRating }}
<watch-button [talk]="talk"></watch-button>
<rate-button [talk]="talk"></rate-button>
`
})
class TalkCmp {
@Input() talk: Talk;
@Output() rate: EventEmitter;
//...
}
主站蜘蛛池模板: 孝感市| 萨迦县| 宾川县| 深泽县| 上犹县| 合肥市| 太原市| 云龙县| 沈丘县| 洮南市| 洪雅县| 阆中市| 秦皇岛市| 荥经县| 蛟河市| 上虞市| 长顺县| 车致| 吉安县| 石台县| 邛崃市| 海原县| 磴口县| 北宁市| 本溪市| 山东省| 临夏市| 北京市| 贵州省| 金塔县| 延吉市| 沽源县| 高雄县| 侯马市| 南皮县| 杂多县| 江津市| 北海市| 高安市| 多伦县| 黔江区|