Can ionic2's pages support nested directory structure?

雨燕双飞 提交于 2019-12-04 16:55:16

Of course it does. In fact, instead of grouping things in terms of what they are (pages, providers, pipes, directives, and so on) I do prefer to group them in terms of what they do just like Angular 2 style guides recommends.

Folders-by-Feature Structure STYLE 04-07

Do create folders named for the feature area they represent.

Why? A developer can locate the code, identify what each file represents at a glance, the structure is as flat as it can be, and there is no repetitive nor redundant names.

Why? The LIFT guidelines are all covered.

Why? Helps reduce the app from becoming cluttered through organizing the content and keeping them aligned with the LIFT guidelines.

Why? When there are a lot of files (e.g. 10+), locating them is easier with a consistent folder structure and more difficult in a flat structure.

Just keep in mind that you'll have to update the references both in all the files and also in the components templateUrl property (if you're not using the RC version). So

@Component({
  templateUrl: 'build/pages/login/login.html',
  pipes: [ ... ],
  directives: [ ... ]
})
...

will turn into:

@Component({
  templateUrl: 'build/pages/auth/login/login.html',
  pipes: [ ... ],
  directives: [ ... ]
})
...

Yes. It does.

You just have to respect the nesting when importing the pages for your NgModule in src/app/app.module.ts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!