Angular Modules

Posted by Christopher Baptiste on October 5, 2020

What is a module?

How does Angular know about our modules?

When we create a module in Angular, the angular object we start with is the Angular core. This is Angular’s core API which allows us to create and load modules using angular.module. Take a look at the exmple below:

In the example above, we are telling Angular that we want to create a module named firstModule by providing the empty array in the second parameter. This is an important thing to note as not providing it would tell Angular that we would like to retrieve it, rather than create it. The number of parameters, is true for anything we set/get in Angular. If we have one parameter, we are telling Angular to get whereas if we have two parameters we are telling Angular to set. For example, if we were to want to enable a downloaded plugin to work in conjunction with our firstModule, we would insert the name of the plugin inside the empty array in the second parameter.