Exploring Modules
In this lesson, we'll learn what modules are and what they contain.
We'll cover the following...
In Angular, there’s a concept called modules. The idea of modules in Angular is similar to ES6 modules in JavaScript/TypeScript. For example, let’s look at a module in vanilla JavaScript.
const foo = 5;
const chocolate = 'dark';
export { chocolate };
In the example above, we have two variables: foo
and chocolate
. The chocolate
variable is exported, which makes it public for other modules to use. The foo
variable is private, which makes it inaccessible outside of the module.
The idea of modules in JavaScript is to split, share, and organize code within your project. Angular expands on this idea by building its own module system for sharing and organizing code. Angular’s module system is much more comprehensive because it allows you to isolate, export, and group code by feature.
The app
module
By default, every project you work on will have ...