The Angular Style guide recommends the use of feature modules (see: app structure & modules). Plus, it seems that source maps for ionic2@RC.0
are also only created for modules – the pages
folder is missing.
So I’d like to create a ./pages/pages.module.ts
that exports all the pages in the default tab
project.
This is what I have:
app.modules.ts
// app.modules.ts
import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
// import { AboutPage } from '../pages/about/about';
// import { ContactPage } from '../pages/contact/contact';
// import { HomePage } from '../pages/home/home';
// import { MappiPage } from '../pages/mappi/mappi';
// import { TabsPage } from '../pages/tabs/tabs';
import { PagesModule } from '../pages/pages.module';
@NgModule({
declarations: [
MyApp,
// AboutPage,
// ContactPage,
// HomePage,
// MappiPage,
// TabsPage
],
imports: [
IonicModule.forRoot(MyApp),
PagesModule.forRoot()
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
// AboutPage,
// ContactPage,
// HomePage,
// MappiPage,
// TabsPage
],
providers: []
})
export class AppModule {}
./pages/pages.module.ts
// ./pages/pages.module.ts
import { NgModule, ModuleWithProviders } from '@angular/core';
import {AboutPage} from './about/about';
import {ContactPage} from './contact/contact';
import {HomePage} from './home/home';
import {TabsPage} from './tabs/tabs';
@NgModule({
imports: [],
declarations: [
AboutPage,
ContactPage,
HomePage,
MappiPage,
TabsPage
],
exports: [
AboutPage,
ContactPage,
HomePage,
MappiPage,
TabsPage
],
providers: []
})
export class PagesModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: PagesModule,
providers: [ ]
};
}
}
But I am missing the import which gives me access to all the Ionic components. I get these errors in the ChromeDevConsole
polyfills.js:3 Unhandled Promise rejection: Template parse errors:
'ion-title' is not a known element:
1. If 'ion-title' is an Angular component, then verify that it is part of this module.
2. If 'ion-title' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("<ion-header>
<ion-navbar>
[ERROR ->]<ion-title>
About
</ion-title>
"): AboutPage@2:4
'ion-navbar' is not a known element:
1. If 'ion-navbar' is an Angular component, then verify that it is part of this module.
2. If 'ion-navbar' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("<ion-header>
[ERROR ->]<ion-navbar>
<ion-title>
About
"): AboutPage@1:2
'ion-header' is not a known element:
1. If 'ion-header' is an Angular component, then verify that it is part of this module.
2. If 'ion-header' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("[ERROR ->]<ion-header>
<ion-navbar>
<ion-title>
"): AboutPage@0:0
'ion-content' is not a known element:
1. If 'ion-content' is an Angular component, then verify that it is part of this module.
2. If 'ion-content' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("
</ion-header>
...