From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Conditional rendering: No product found - Nest.js Tutorial
From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework
Conditional rendering: No product found
So, currently, we are rendering the static product data inside the home page. Eventually, we will implement the functionality which renders the product data from the database. But still, when there won't be any data inside the database, there has to be an appropriate message displayed to the users. And that's exactly what we are going to create in this lecture. So we already have an if condition to render the products from the array. Now all we need to put is an else part. So here after the ending of if block, I'll give the else block. I'll open the curly braces and to close the curly braces, I'll give another ejs scriptlet and closing the curly bracket. Inside I'll give a division and an h1 with the message, no products available. And an anchor tag that redirects to the ad product page. For now, the reference will be set to a hash sign. Let's check the output now. And the message and link is getting displayed. Let's style them using the bootstrap classes. For division, I'll give…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Introduction to MyStore application2m 43s
-
(Locked)
Rendering template on server4m 41s
-
(Locked)
Creating navbar with "includes"3m 31s
-
(Locked)
Creating home interface9m 6s
-
(Locked)
Conditional rendering: No product found2m 26s
-
(Locked)
Configuring add product route2m 29s
-
(Locked)
Creating "add product" interface5m 51s
-
(Locked)
Configuring edit product route1m 49s
-
(Locked)
Interface & functionality: Edit product4m 10s
-
(Locked)
-
-
-
-