Rendering tags

We now have a service that uses a reactive approach to generate tags from the available projects. This already addresses the first concern of our service. Let's look at its other responsibility, which is parsing text content for tags and rendering HTML.

Before we start writing our parse method in the tags service, we need to create a small utility function for string replacement. Open the file src/app/utilities/string-utilities.ts, where we have already created our limitWithEllipsis function, and add the following code:

export function replaceAll(  target: string,  search: string,  replacement: string): string {  return target.split(search).join(replacement);}

The preceding method uses a small JavaScript trick to replace all occurrences ...

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.