An Introduction to NgModule for Ionic 2

By Josh Morony

We all use it, it’s a critical part of our applications structure, but I think a lot of people are confused by what exactly it is and what it does. I’m talking about the @NgModule in the app.module.ts file in an Ionic 2 application.

In short, using modules allows us to organise our application into cohesive blocks of functionality. All applications will have a root module which will define dependencies like the components, directives, pipes, and providers that the application will use, and also any other modules that the application should import.

One example of a module we always use (and it is usually the only additional module aside from the root module) in Ionic 2 applications is IonicModule. We import this into our root module, and by doing that we automatically gain access to all of Ionic’s many components and directives. The module handles importing and declaring all of the Ionic specific stuff for us, so we don’t need to manually import the List component, or the Slides component into our own root module every time we want to use them.

Read the full article...

Share on Google Plus

About www.

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment


Post a Comment