Fireship · @fireship
Angular Components Beginner's Guide
Uploaded June 20, 2018 · Length 13:52
Summary
This video teaches how to create and use Angular components, including binding data, events, and interpolation, and how to use directives like ngIf and ngFor.
- angular components
- angular beginner's guide
- angular development
- typescript
- html templates
- angular directives
- ngif
- ngfor
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
[Music]
- 0:06
components are like the LEGO pieces of
- 0:08
an angular application if you don't know
- 0:10
how to put them together properly you're
- 0:11
not going to be able to build anything
- 0:12
cool over the next 10 minutes or so I'll
- 0:14
show you all of the basics and angular
- 0:16
components and how to piece them
- 0:18
together in an application
- 0:19
this video is beginner level so if you
- 0:21
know a little bit about JavaScript and
- 0:23
web development you should be okay if
- 0:25
you're new to the channel make sure to
- 0:26
LIKE and subscribe and grab the full
- 0:28
write-up from angular firebase com the
- 0:31
first question we need to answer is what
- 0:32
is a component in the first place and I
- 0:35
think the most simple answer to this
- 0:36
question is that it's just a controller
- 0:38
for the user interface as a developer
- 0:41
you write components to control how your
- 0:42
app is experienced by end-users to show
- 0:45
you this in practice I'm opening a brand
- 0:47
new angular 6 app that was generated
- 0:49
with the CLI then I'm generating a new
- 0:52
component called home which you'll
- 0:54
notice creates four different files in
- 0:56
the app directory the vast majority of
- 0:58
the logic that you'll write will be in
- 1:00
the home component ES file the component
- 1:03
itself is just a typescript class but it
- 1:05
uses this component decorator to
- 1:06
sprinkle in some angular magic the most
- 1:09
important thing is that it allows us to
- 1:11
bind data from this typescript file to
- 1:13
the HTML template the first thing I want
- 1:15
to show you is how to bind typescript
- 1:17
code to your HTML let's define a
- 1:19
property on this class called clicked
- 1:21
that defaults to false now let's go into
- 1:23
the HTML and let's imagine we have a
- 1:25
button that we want to disable after
- 1:27
it's been clicked we combined our
- 1:29
typescript data to this attribute in
- 1:31
HTML by wrapping it in square brackets
- 1:33
disabled isn't something angular
- 1:35
provides it's an actual attribute on the
- 1:37
HTML element which I'm looking at here
- 1:39
in the Mozilla documentation the special
- 1:42
thing about angular is that we can wrap
- 1:43
this attribute in square brackets and
- 1:45
then bind it to our type script so
- 1:47
instead of just passing it a boolean
- 1:49
value like false we can actually pass it
- 1:51
our clicked property which we can then
- 1:52
toggle on our typescript as needed it's
- 1:55
currently set to false so we should be
- 1:56
able to serve our app and the button
- 1:58
should be clickable which it is if we go


