O'Reilly logo

Mastering Angular Components by Gion Kunz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building the comment component

Let's start making our commenting system by fleshing out the comment component first. In addition to the comment itself, we'd like to display the user's profile, who commented, and the time of the comment.

To display the time, we will make use of relative time formatting, as this will give our users a better feel of time. Relative time formatting presents timestamps in the format "5 minutes ago" or "1 month ago", in contrast to absolute timestamps, such as "25.12.2015 18:00". Using a famous third-party library called Moment.js, we'll create a view pipe that we can use within component templates to convert timestamps and dates into a relative time format.

View pipes are a great way to enrich the template language ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required