Ionic 3,深层链接:每个@IonicPage组件都必须有自己的.module.ts吗?

时间:2017-06-23 14:23:12

标签: angular ionic-framework ionic3

考虑到以下Ionic3项目结构,我需要深层链接以正确反映当前的" breadcrumb"在网址中。

enter image description here

主要问题:必须我有src/pages/journal/add-entry/add-entry.module.ts个文件?或者src/pages/journal/journal.module.ts可以将子文件夹中的所有@IonicPages以及它自己的journal.ts组件集中在一起,如下面的代码片段所示?

journal.module.ts

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { JournalPage } from './journal';
import {AddEntry} from "./add-entry/add-entry";

@NgModule({
  declarations: [
    JournalPage,
    AddEntry
  ],
  imports: [
    IonicPageModule.forChild(JournalPage),
    IonicPageModule.forChild(AddEntry),
  ],
  exports: [
    JournalPage,
    AddEntry
  ]
})
export class JournalModule {}

journal.ts

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';

@IonicPage()
@Component({
  selector: 'page-journal',
  templateUrl: 'journal.html',
})
export class JournalPage {}

添加-entry.ts

import { Component } from "@angular/core";
import { IonicPage } from "ionic-angular";

@IonicPage()
@Component({
  selector: "page-add-entry",
  templateUrl: "add-entry.html"
})

export class AddEntry{}

0 个答案:

没有答案