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 ...

Get Mastering Angular Components 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.