神刀安全网

A 60 second whirlwind tour of Angular 2 components

Quick Tip

Whenever you see a word or phrase with this color , click on it to highlight the source code. Click it again to remove the highlight.

This is an Angular 2 component.

Components define custom elements such as <todo-list> , <user-details> or, in our case, the <block-counter> element which we’ve added to our index.html page.

The component class is written in TypeScript and defines the data and behavior for the component. The @Component decorator provides additional meta-data for the class.

So when the application starts, Angular will locate the <block-counter> element using selector , insert the contents of the template between the tags, and apply the CSS rules specified in the styles property.

The template accesses properties and calls methods on the component class using property bindings, event bindings and interpolation. You can see how in the Template Syntax Whirlwind Tour .

Where To Next?

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » A 60 second whirlwind tour of Angular 2 components

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
分享按钮