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

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;
//...
}
主站蜘蛛池模板: 灵台县| 龙南县| 安远县| 小金县| 额尔古纳市| 松潘县| 枣庄市| 石阡县| 嘉荫县| 车险| 冷水江市| 柳江县| 隆化县| 若尔盖县| 鹤岗市| 赤水市| 土默特右旗| 称多县| 扎兰屯市| 峡江县| 崇信县| 台东县| 井冈山市| 麻栗坡县| 安康市| 伊吾县| 隆昌县| 南丹县| 姚安县| 建水县| 禄丰县| 万山特区| 河源市| 剑河县| 洪雅县| 恩平市| 应城市| 石嘴山市| 芦山县| 灯塔市| 疏附县|