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

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;
//...
}
主站蜘蛛池模板: 义马市| 浪卡子县| 冕宁县| 辽宁省| 浑源县| 万年县| 保靖县| 锡林浩特市| 喀喇| 苏尼特右旗| 乐清市| 德州市| 汶上县| 苍梧县| 武平县| 达拉特旗| 涟源市| 龙川县| 柳江县| 商南县| 江华| 高雄市| 苏尼特右旗| 册亨县| 陆良县| 洪洞县| 广州市| 芒康县| 霍州市| 玉屏| 金堂县| 临沧市| 淄博市| 台东市| 通州市| 德阳市| 赣州市| 察哈| 白城市| 财经| 五峰|