-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Encapsulate pages inside feature modules #53
Comments
@SamVerschueren Sounds great to me. Largely aligns with how I do things in Angular 2 Web Applications using feature modules 👍 @samvloeberghs: Would be great to hear your thoughts as well. What do you think? |
That's how I do it as well. Currently we have to bootstrap and expose services, components, pipes, ... in the root and they're visible and can be used by everyone which is usually not what you want. I can do a small refactoring of one page and do a PR to make it more clear. |
If Ionic 2 allows the use of feature modules, then I can't think of a reason not to use them. Unless @samvloeberghs has any particular arguments against them here. Thanks for your great work @SamVerschueren, much appreciated! 👍 |
They allow it, it's just not documented by them. It should be part of their tutorial imo.
My pleasure :) |
I'm all up for modules :) |
#wontfix, repo deprecated |
Alright, this might be a little bit hard to explain, I'll do my best :).
So yesterday, I dived more into Ionic 2. I like how easy it is to get something good looking on the screen. What I dislike however is the structure. Pages are just components, nothing more nothing less. Why? Why aren't they modules that encapsulates everything from within that page. It could even encapsulate child pages... In my opinion, that would make much more sense.
Let's give you an example.
The schedule page has quite some html in the template file. Normally, you would work with dumb components to split everything apart. For instance, the session list is written like this.
It would be much cleaner if we extracted the session item to a separate dumb component and work with a
session
input or something like that.And embed the
ion-item
component inside thesession-item
.With the current structure however, this would require us to actually bootstrap the
SessionItemComponent
at the root module of our application. Dirty!Solution
ScheduleModule
which encapsulates everything inside the schedule page. You could add services, other components, pipes, etc without having to bootstrap them at the root for everyone.index
barrel file that exports the module and the page. We need the page so we can navigate to it.AppModule
and removeSchedulePage
fromentryComponents
.That's basically it. In my opinion, a much better separation which allows you to easily create extra dumb components in order to keep your code clean. The
ConnectionService
can now be part of theScheduleModule
(if we don't need it somewhere else) and follows the Angular 2 way of thinking.Let me know what you think.
The text was updated successfully, but these errors were encountered: