The ng-container Element

Learn how the ng-container element can help us use multiple directives.

We have a functioning image gallery. It’s simplistic, but there’s one problem with it. The pagination buttons can grow to take up the entire page if there are more images than we currently have. It looks OK with six images, but if there were dozens of images, it wouldn’t look appealing anymore.

Let’s look at how other sites handle large search results. Google will show links to the next set of results, even if there are a lot more. For example, if you search for “pizza,” you’ll see their pagination links look like this:

There are over 2 billion results, but they’re limiting the number of links in their pagination to 10 pages at a time. We’ll want something like this when displaying the pagination buttons.

Applying the ngIf directive

We can use the ngIf directive to help us limit how many pagination buttons should be displayed at a time. We’ll apply the ngIf ...