Angular 2 fundamentals

An Angular 2 application is completely split into components. Technically, an Angular 2 component is a reusable custom tag that is mutable and encapsulated with an embedded state, that is, changes to the state or properties will mutate the UI.

Note

Remember that Angular 2 doesn't register the custom tag name as a custom element.

All the components of the application are arranged in a tree structure, with a component as the root node.

Here is an example of how to create a component. It creates a card component that displays an image, title, and description. Place this code in the <script> tag:

var Card = ng.core.Component({ selector: "card", inputs: ["src", "title", "desc"], templateUrl: "templates/card-template.html", styleUrls: ...

Get JavaScript: Moving to ES2015 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.