Course - Ng-Bootstrap Playbook
Course - Ng-Bootstrap Playbook
Introduction
Introduction
Hi. This is Steve Michelotti. Welcome to the ng-bootstrap Playbook course
on Pluralsight. Over the last few years, Bootstrap has risen to prominence as the world's
most popular layout and componentlibrary. At the same time, Angular has dominated as
a framework to build single-page applications. Ng-bootstrap brings these two libraries
together in a seamless way, and that is the focus of this course. This will be a
completely code focused course in which we'll build an app from scratch. This is a
preview of the app that we'll be building. It's a simple app to help an individual
track their workouts of biking, running, and rowing. Here's the screen that shows all of
our previous workouts and tracks our progress towards our targets. And here's a quick
look at the data entry screen using ng-bootstrap components. For example, a datepicker
you see right here. Along the way, we'll add many enhancements to our app using ng-
bootstrap. I'll show you how quick and easy it is to get up and running with ng-
bootstrap.
Course Overview
Here's an overview of what you can expect from this course. In this first introductory
module, I'll talk about what ng-bootstrap is. I'll also discuss helpful prerequisites and
briefly show you the app that we'll be building throughout this course.
Then we'll dive immediately into code and I'll walk you through the initial app setup
with Angular, Bootstrap CSS, and a back-end HTTP web API. This is the setup even
before we incorporate ng-bootstrap.
In the basic forms module, I'll cover all the ng-bootstrap components that
would typically be used when building forms. These include things like buttons,
the datepicker, timepicker, and more.
I'll then go into depth on the various ng-bootstrap components to enable you to structure
and organize the information the way you want. These are things like modal dialogs,
tabs, and accordions.
In the next module, I'll show you how easy it is to use the various informational
components in ng-bootstrap. These are typically things you'd use to give quick guidance
or feedback to the users of your apps. These are things like tooltips, popovers, andalerts.
In the final module, I'll cover a couple of navigational components. This will be
centered on paging through large grids of data.
What Is ng-bootstrap?
The most important question we need to answer first is what is ng-bootstrap? Let's
answer this question first, then dive into the details. In short, ng-bootstrap provides a
native Angularimplementation for Bootstrap components. Let's explore what we mean
by this a little more closely. Bootstrap itself consists of a couple of things. Number one,
it provides base CSS for layout, content, and other display aspects, and number two, a
JavaScript library for rich client-side components. These JavaScript components in
Bootstrap have historically been based on jQuery. So having answered the mechanical
question of what is ng-bootstrap, let's focus on the why. Why would we want ng-
bootstrap? Well, there are a few reasons. First, if you're already building an app with
Angular, you know there's a certain style we use for implementation with data binding
and TypeScript. This is very different from a jQuery-based approach, so it's
quite valuable to have an implementation that is native to the platform. There are
also tremendous performance and efficiency benefits for using native Angular
code. And in general, it will make our applications smaller if we can avoid the jQuery
dependency. Let me show you some concrete examples so we can more fully grasp this.
Here I am on the home page for Bootstrap itself. Let's click into the Documentation.
And as you heard me mention, Bootstrap already provides CSS for layout and other
things. For example, if I click into the Layout, we can see things like the famous
Bootstrap grid system. If I click into Content, we see various CSS for things like
Headings, Lists, Forms, and much more. So those first two things I showed you are
reallyfocused on the CSS that provides the layout and the visual aspects. But then that
second aspect you heard me mention has to do with components. Let's
click Components right here, and the first thingyou'll see is the Components listed
here, and the navigation on the left will look very familiar to you when we look at
the ng-bootstrap components because these are the components that ng-bootstrap
is focused on. For example, let's click into the Modal. As we scroll down, you can
see code examples of the Modal. And right off the bat, you can see this is a very jQuery-
centric implementation, and thiswould not be natural to write this type of code in an
Angular app. But we can also come down here and see live demos, and I can launch the
Modal dialog. This is the type of functionality we'll get with the ng-bootstrap library,
but with a native Angular implementation. Now let's flip over to the ng-bootstrap
website. This is your starting point for ng-bootstrap. Let's click on the Demo button, and
right off the bat you can see the list here of Components on the left side look
very familiar to the Components that we just saw on the Bootstrap site. And we're
going to cover every single one of these Components in this course. For example,
we can click the Modal, and now we see a TypeScript-based code example. Now
this looks like what we expect in an Angular app as opposed to that jQuery example.
Yet when we launch the demo, we get the same functionality. We even have a
datepickercontrol incorporated into this modal, in fact. Another nice thing about ng-
bootstrap is that it's completely open source. So I just clicked the button for the GitHub
site, and all the code is right here. In addition to that, you can click on the Issues tab
right here if you find any issues and you need to log a bug, for example. However, if
you just have a question about the library itself, and not necessarily a bug, then the
Issues tab is not where you should put that. If you're seeking help for ng-bootstrap, then
what's really nice is you can click this link here, Getting Help, this just takes us further
down the page, and notice the link for StackOverflow. There's a link here
for StackOverflow where you can get answers to ng-bootstrap questions. Now that
we're starting to get a solid foundation for these concepts, I just want to show one brief
demo to continue to drive these concepts home. Here I am in an empty VSCode
environment and I'm going to use the integrated terminal in VS Code to run a very
simple npm install command to simply install the baseline bootstrap library. Now I'm
actually not going to use thebaseline Bootstrap library at all in this course, I just want
you to see what comes with it. If I expand bootstrap, specifically the dist folder, we're
going to see that we have two folders, css and js, just like we've been talking about. If I
expand the css one, the only file we'd have to include in a traditional app is bootstrap.
min. css, as we can see right here. When we build our custom app, I'm going to use a
custom Bootstrap theme that you'll see me download from bootswatch. com, which is a
site that provides free Bootstrap templates with more interesting colors than the default.
So I actually won't even use the default CSS that comes with Bootstrap. Then if I
expand the js folder, we'll see bootstrap. min. js, and we absolutely won't use this file
because all the JavaScript functionality will be provided solely by ng-bootstrap. So
even though we're not using the Bootstrap library at all in this course, I want you to see
what's in it so you can understand which parts we are replacing with ng-bootstrap.
Helpful Prerequisites
There are a couple of prerequisites for this course that I strongly recommend you have.
And based on what we've already discussed, it won't be hard for you to guess them. It's
highly recommended thatyou have some familiarity with both Bootstrap and Angular.
This is a course that is focused on how to use the ng-bootstrap library. It's not a
course intended to introduce you to Bootstrap or Angular for the first time.
Fortunately, Pluralsight has you more than covered here. There are already numerous
Angular courses in the Pluralsight library. For Angular, I recommend checking out
the Angular learning path on Pluralsight, which you can see in this link here. It covers a
range of courses from beginner toadvanced. And if we scroll down, you can see
Beginner, Intermediate, Advanced, but Beginner is certainly sufficient for this course.
For Bootstrap, you can simply come into the Pluralsight search box and fill in bootstrap
as your search term, and you'll come up with a ton of courses. And most any of these
courses can give you great familiarity with Bootstrap. And again, a beginner level of
knowledge of Bootstrap is sufficient for this course. One thing to keep in mind is that
although there are lots of Bootstrap courses at Pluralsight, this course uses the
latest version of Bootstrap, which is Bootstrap 4. Therefore, it would also be a good
idea to check out the Bootstrap 4 course on Pluralsight, which you can see right here.
Course Repository
Technology changes incredibly fast these days. That means that library APIs
can change, and as a result, courses like this can easily go out of date. Because of this, I
created this GitHub repository, and I'll make sure to post information containing key
files you need to have, as well as information about whether the course is up to date and
potential workarounds you can use if it's not.
What We Will Be Building
Let's take a quick sneak peek at the app that we'll be building from scratch throughout
this course. Here I have the Workouts screen where I can set performance targets, we
see progress bars where we can track our performance targets. Down here we can see a
grid of various previous workouts. And we can see that we can page through the grid. I
can add a new entry, we have datepicker controls, timepicker controls, rating controls,
an ability to put in distance. We also have other sections of the app we can page
through, images. And every once in a while, I'll use somewhat contrived examples. For
example, on the home screen you have a collapsible panel where it doesn't do anything
useful, but I'll be able to use it to illustrate how the collapsible panel works. As we go
through the course, I'm going to show every single component that the ng-bootstrap
library currently contains. So with that, let's get started. It's time to start building our
app and using the ng-bootstrap library.