Fireship · @fireship
Reactive Forms - The Basics
Uploaded May 22, 2018 · Length 15:48
Summary
Learn how to create reactive forms in Angular 6 with examples of form controls, validation, and dynamic form fields.
- angular reactive forms
- angular form controls
- form validation angular
- dynamic form fields angular
- angular material forms
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
[Music]
- 0:02
today I'm going to show you everything
- 0:04
you need to know to start using reactive
- 0:05
forms in angular 6 effectively we'll do
- 0:08
this by building five different forms
- 0:10
that started the absolute basics then
- 0:12
progress on to topics like dynamic form
- 0:14
fields validation and submitting your
- 0:16
form data to a back-end database almost
- 0:19
all apps use forms in some capacity so
- 0:21
understanding reactive forms is a very
- 0:23
valuable skill to have as an angular
- 0:25
developer if you're new make sure to
- 0:27
subscribe and grab the source code from
- 0:29
angular firebase comm and I'll be giving
- 0:31
away three free hats on Friday all you
- 0:33
have to do is leave a comment on this
- 0:34
video I'll be starting off here from an
- 0:37
angular 6 project and the first thing
- 0:39
I'll do is add angular material to this
- 0:41
project because it has some awesome UI
- 0:43
elements for form validation you can
- 0:46
install it in your project by running ng
- 0:48
add angular slash material then I've
- 0:51
already generated five different
- 0:52
components that I'm going to use to
- 0:53
demonstrate these different reactive
- 0:55
form examples if you don't know how to
- 0:57
generate components with the CLI make
- 0:59
sure to watch episode 104 from last week
- 1:01
the reactive forms module isn't included
- 1:04
by default so we're going to import that
- 1:06
from angular forms and then we have a
- 1:09
bunch of modules that were importing
- 1:10
from angular material that handled
- 1:12
different form fields that we want to
- 1:14
use then all of these modules will be
- 1:16
added down to the import section giving
- 1:18
us access to these various components
- 1:20
and services when it comes to angular
- 1:22
material there's a whole bunch of
- 1:23
different form elements that you can use
- 1:25
so make sure to check out the docs and
- 1:27
experiment with some of the examples
- 1:28
there
- 1:29
the first reactive form we'll build
- 1:31
starts with the absolute basics let's
- 1:34
see how we can set up a few form
- 1:35
controls for an email a message and a
- 1:38
select field for a career then we'll
- 1:40
observe the changes to the actual values
- 1:42
being entered into this form you'll
- 1:45
notice that every time we enter
- 1:46
something into this form it updates the
- 1:48
value object that's because under the
- 1:50
hood the form is using rxjs to treat the
- 1:53
form as a reactive real-time stream
- 1:55
let's go ahead and jump into the type
- 1:58
script for this component and we'll take
- 1:59
a look at what we need to build the


