0

Angular – Bootstrap Another Module other than AppModule

This post demonstrates how to change a newly created Angular project to use another @NgModule other than the default AppModule class.

Requirements

  • Angular CLI
  • NPM 6.4.1
  • Node v8.11.3
  • Internet connection

Setup

Install Node and NPM first before Angular CLI.

Create a new Project

Next, invoke this command on the command-line prompt to create a new Angular project:

New Module

For this purpose, we just need to make a copy of the app folder and its contents. Then, modify the new files to point to the correct files within the same folder.

Modify main.ts

Modify main.ts to use the new @NgModule class in app2/app2.module.ts

If the project is currently served via ng serve, stop and start it.

Testing

We now load a new @NgModule.

Download the Files

https://github.com/Turreta/Angular-Bootstrap-Another-Module-other-than-AppModule

Karl San Gabriel

Karl San Gabriel

Java and Enterprise Technologies Expert