Angular 2 RC 5 NgModules
Angular Modules, also known as NgModules, are the powerful new way to organize and bootstrap your Angular application. In this screencast we upgrade the ng2play repo to the latest release candidate (RC5).
Here are the links related to the screencast.
We basically follow the migration steps in the guide, which are:
- Update to RC5: We do this by simply bumping the versions in packages.json and running npm install.
- Create an NgModule: Create a root NgModule in app.module.ts that we use to bootstrap our application.
- Update your bootstrap: Updated main.ts to bootstrap our module instead of our root component.
- Update your 3rd party libraries: We load up the Forms, Material, Router and Http module in our main app module.
- Cleanup: Clean up the code by getting rid of repetitive boiler plate code in our Component annotations.
A couple of months ago I did a rant on forms in angular, and finally they are starting to adress some of the issues. For instance it wasn’t possible to reset a form and its validation in earlier versions, which now is possible. We can simply call a reset method on either a form group or a single control.
Modules is definitely something that we needed to be able to get rid of a lot of boiler plate code in our components. Even if my opinion is that it’s a bit late to introduce this in between two release candidates the end result weighs up for it. I’ll try to do a separate screen on lazy loading modules, which is really easy now.
Hope this screencast helped you migrate to RC5 and learn more about modules in Angular.
Until next time, have an excellent day!