The page has the @IonicPage decorator, but it doesn't have a corresponding "NgModule"
This is because the decorator @IonicPage()
is for deep linking, this will register the page with the ionic deep linking system .
You can remove the decorator if you don't need deep linking on this page.
Or you can register this page in yours YOURPAGE.module.ts
with this code:
@NgModule({
declarations: [
MyPage
],
imports: [
IonicPageModule.forChild(MyPage)
],
entryComponents: [
MyPage
]
})
More information can be found in the docs
source to share
If you want to deep link, read the API doc first
and now let's look at an example of adding a deep anchor page:
This is our src folder structure:
-src
--app
--assets
--pages
--home
*home.html
*home.scss
*home.ts
--thems
*some file we not working with them in here
to add a page use this command in your application folder:
$ ionic g page show
show is the name of the page. and now this is our src folder structure:
-src
--app
--assets
--pages
--home
*home.html
*home.scss
*home.ts
--show
*show.html
*show.scss
*show.ts
--thems
*some file we not working with them in here
If now you start your application with the following command in your application folder:
$ ionic serve
you get an error like this:
/path/to/app/src/pages/show/show.ts has a @IonicPage decorator, but it doesn't have a corresponding "NgModule" in /path/to/app/src/pages/show/show.module.ts
now you should make a file named show.module.ts
(by mistake it says) in the show folder, then our src folder structure should look something like this:
-src
--app
--assets
--pages
--home
*home.html
*home.scss
*home.ts
--show
*show.html
*show.scss
*show.ts
*show.module.ts
--thems
*some file we not working with them in here
and this is the content of the file show.module.ts
:
import { NgModule } from '@angular/core';
import {IonicPageModule} from 'ionic-angular';
import { ShowPage } from './show';
@NgModule({
declarations: [
ShowPage
],
imports: [
IonicPageModule.forChild(ShowPage)
],
entryComponents: [
ShowPage
]
})
export class ShowPageModule {}
Done. run the app with ionic serve
and the error is gone.
You can go to a new page with
goToMyPage() {
// go to the ShowPage component
this.navCtrl.push('ShowPage');
}
source to share
When you add a page using Ionic CLI like
ionic page generation newPage
then it automatically generates the newPage.module.ts file and inside newPage.ts it generates a line of text as
@IonicPage ()
Well, you should remove newPage.module.ts and remove @IonicPage () from newPage.ts
then open app.module.ts and add newPage inside the declarations and login components.
source to share
On the .ts page, add the following code, replace the word "name" with whatever you name on your page. Don't forget to add a new page to your app.module.ts page.
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-name',
templateUrl: 'name.html',
})
export class NamePage {
constructor(public navCtrl: NavController) {
}
}
source to share