Component styles

Components parade reusability a lot. In fact, that's the first answer you get when you ask about the benefits of using the component architecture. This is the reason why templates and styles are scoped to the component rather than littering the app's environment with heavy HTML and CSS.

The styleUrls property in the component's decorator argument takes an array of URLs pointing to the styles you want to apply to the component. Most of the time, you just need a single file; therefore, the array will only contain a single URL item, in our case, app.component.css. It's currently empty but we can carry out an experiment with it:

* {    background: red; }

The * selector is supposed to select everything in the document. So, we say, ...

Get TypeScript 2.x for Angular Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.