Skip to Main Content
Mastering Angular Components - Second Edition
book

Mastering Angular Components - Second Edition

by Gion Kunz
July 2018
Intermediate to advanced content levelIntermediate to advanced
402 pages
9h 35m
English
Packt Publishing
Content preview from Mastering Angular Components - Second Edition

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Angular, 2nd Edition

Learning Angular, 2nd Edition

Brad Dayley, Brendan Dayley, Caleb Dayley
Essential Angular

Essential Angular

Victor Savkin, Jeff Cross
Pro Angular 6

Pro Angular 6

Adam Freeman

Publisher Resources

ISBN: 9781788293532Supplemental Content