- Overview
- Transcript
2.1 Bootstrapping the Application
All Angular apps must be bootstrapped in order to load them in the target environment. In this lesson we take a look at the main entry point for our application, which is where this bootstrapping takes place.
1.Introduction6 lessons, 42:00
1.1Introduction00:48
1.2Get Started With Angular-CLI11:09
1.3Developing With Angular-CLI13:17
1.4TypeScript vs. JavaScript06:54
1.5Angular Modules From the CLI04:31
1.6CLI Options05:21
2.Get Started With Angular7 lessons, 42:38
2.1Bootstrapping the Application04:30
2.2The Application Module04:15
2.3The Application Component08:06
2.4Component Styling03:06
2.5Global Styling05:11
2.6Creating a Component With the CLI09:34
2.7Creating a Service With the CLI07:56
3.Core Concepts7 lessons, 55:20
3.1Component Trees06:20
3.2Dependency Injection06:52
3.3Content Projection05:38
3.4Component and Directive Lifecycle Methods06:31
3.5Component-Only Lifecycle Methods05:28
3.6Decorators07:36
3.7Models16:55
4.Template Deep Dive11 lessons, 1:10:56
4.1Basic Data Binding With Interpolation05:35
4.2Property Bindings07:07
4.3Attribute Bindings03:29
4.4Event Bindings08:16
4.5Class and Style Bindings05:44
4.6The `NgClass` and `NgStyle` Directives05:04
4.7The `*ngIf` Directive04:41
4.8The `*ngFor` Directive09:29
4.9Inputs05:33
4.10Using Pipes in a Template07:31
4.11Using Pipes in a Class08:27
5.Forms10 lessons, 1:45:41
5.1Handling User Input With Template Reference Variables07:06
5.2Template-Driven Forms11:10
5.3Template-Driven Forms: Validation and Submission14:00
5.4Reactive Forms11:26
5.5Using a `FormBuilder`08:01
5.6Reactive Validation With Built-in Validators14:53
5.7Creating Custom Validators for Template-Driven Forms12:18
5.8Creating Custom Validators for Reactive Forms08:26
5.9Observing Form State Changes12:40
5.10Working With the `@HostListener` Decorator05:41
6.Routing9 lessons, 1:15:10
6.1Defining and Configuring Routes07:53
6.2Rendering Components With Router Outlets10:14
6.3Using Router Links for Navigation05:25
6.4Navigating Routes Using the Router06:24
6.5Determining the Active Route Using an Activated Route07:16
6.6Working With Route Parameters10:42
6.7Using Route Guards07:36
6.8Observing Router Events10:55
6.9Adding Child Routes08:45
7.Using the HTTP Client5 lessons, 56:24
7.1Sending an HTTP Request10:52
7.2Handling an HTTP Response11:22
7.3Setting Request Headers12:33
7.4Intercepting Requests09:04
7.5Finishing the Example Application12:33
8.Testing10 lessons, 1:23:27
8.1Service Unit Test Preparation10:45
8.2Unit Testing Services13:24
8.3Component Unit Test Preparation12:35
8.4Unit Testing Components07:27
8.5Unit Testing Component Templates06:58
8.6Unit Testing Pipes04:41
8.7Unit Testing Directives04:56
8.8Unit Testing Validators04:48
8.9Unit Testing Observables11:37
8.10Unit Testing HTTP Interceptors06:16
9.Building for Production1 lesson, 03:40
9.1Building for Production03:40
10.Conclusion1 lesson, 01:32
10.1Conclusion01:32
2.1 Bootstrapping the Application
Hi folks. In this lesson we can take a look at how an Angular application is bootstrapped, which is like an initialization process whereby it is loaded in the browser. Angular apps don't have to be loaded in the browser. They can also run in NodeJS or other environments. When we do want to run an app in the browser, we need to Bootstrap it specifically for the browser. Because an Angular application is modular, it needs to have an entry point defined, which is where the module loader can load the initial module, which loads the rest of the application. The CLI has created an entry point for us. This is the main.ts file which is in the src directory. Let's open it up and take a look. At the top of the file, there are some import statements. These are interesting because they use the ES module syntax. The import and from keywords are pure JavaScript. Unfortunately, they aren't yet supported in all mainstream browsers, which is why we have to have Webpack in the project to load the modules for us. So the import keyword is followed by the identifier that we want to import within curly braces. Depending on the type of export that we're working with, we may or may not need the curly braces, but for most, maybe even all of the Angular imports, will import specific identifiers using this curly bracket syntax. We then use the from keyword to specify the path to the file that contains the identifier that we want to import. Webpack has some mappings in place, so we don't need to explicitly reference the node modules folder, which is where all of the Angular modules that we'll be using reside. After the Angular imports, we then have some application specific imports. We import the app module from the app.module file in the app folder, and the environment file from the src folder, which is the root of the application. After the imports, we then check whether we're running in production mode. At the moment, and for most of the time while we're developing, we'll be running in development mode and not production mode. Angular apps run in development mode by default, and if we want to run in production mode, we need to specifically tell Angular to do this. We can tell Angular to run in production mode using the CLI, and we'll take a look at this right at the end of the course. So when we do run a production build, environment.production will be true and we can signal to Angular to run in production mode by calling the global enable prod mode function. This was one of the things that we imported from the core Angular module at the top of the file. There are a number of differences between development mode and production mode. In production mode, our component templates will be pre-compiled. The generated JavaScript and CSS files will be concatenated and minified, and unused or dead code will be eliminated from the resullting package. None of these things are useful in development however, so they are only enabled in production mode. For loading the app in a browser, which is what we want to do most of the time, certainly in this course, we'll use the Bootstrap module method of the platform browser dynamic module. We pass in our own app module which is the root module of our application. This method returns a promise and has a catch method attached to handle any errors in the bootstrapping process. So this file already does everything that we need it to do. Even once we've completely built the application, this file won't need to change at all. Separating the booting of the application from the application itself like this is a great design. It means that we just don't need to worry about this file again. I just want to point out again, I did mention it already, but just so that we're clear, Angular uses the Webpack module loader under the hood to handle loading modules in the application. This is all configured for us automatically and we generally won't need to make any configuration changes to Webpack itself. So in this lesson, we saw that we can Bootstrap our application relatively easily using a couple of Angular modules. Remember, all bootstrapping is, is loading our root module. We also learned that we can handle running in production and development modes easily using the enableProdMode() method, which basically just handles everything for us. And that we used the bootstrapModule() method to bootstrap the app module. Thanks for watching.