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

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;
//...
}
主站蜘蛛池模板: 昌平区| 确山县| 临安市| 揭阳市| 荆州市| 准格尔旗| 平顺县| 东阳市| 古交市| 祁阳县| 都兰县| 鹿泉市| 五寨县| 宜阳县| 商洛市| 阳西县| 武宣县| 阿克陶县| 当雄县| 清丰县| 浦江县| 大石桥市| 甘谷县| 延安市| 江北区| 松滋市| 岫岩| 天台县| 安康市| 德州市| 巴里| 浦城县| 巴林右旗| 隆子县| 历史| 迁西县| 游戏| 邯郸市| 樟树市| 建宁县| 甘南县|