Martin Martin - 25 days ago 8
AngularJS Question

Angular 1.5: Components and use of angular modules?

I am trying to adopt the new .component released in angular 1.5. Although I am having a tough time understanding where modules fit in now.

Before I used to separate my components into angular modules, what relationship does this have now that components are here ?

Just create one angular module and add all components under this, or continue to use angular modules as well as components ?

The documentation doesn't seem to go into this. If I am still using modules then what is the use of components, or if I am using components what is the use of more than 1 module ?

I would really appreciate any feedback as I am confused about how to proceed.

Thanks

Answer

Components in Angular 1.5 are a replacement of controllers. They are more like directives on steroids.

Before I used to separate my components into angular modules, what relationship does this have now that components are here ?

Now that the components are there you can separate related components into different modules.

Just create one angular module and add all components under this, or continue to use angular modules as well as components ?

You can use the same pattern you used before to separate out the controllers.

components in angular 1.5 help you create actual components that have their own view and bindings. They were created to allow angular 1.5 devs understand the pattern and migrate easily to Angular 2.0 later.