I got project, previous developer told, that used Ionic 3.
I don’t understand, what folder structure must to be.
Angular developer told, that all code must to be inside src/app folder.
But in my case, all code just inside /src folder - pages, providers, directives etc in one nesting level with “app” folder
My folder structure
src
app
directives
providers
pages
As my friend angular developer told, all code must be in src/app folder and structure must be like
src
app
directives
providers
pages
When I use in terminal command “ionic generate page|provider|directive” from different places (/src/, /src/app or even project root directory)
all this folders generates in src/ folder near app/ folder, but not inside it.
Is it right?
As I looked here https://github.com/ionic-team/ionic-conference-app/tree/master/src
all code places inside app/ folder.
I have Ionic CLI 4.8.0
IONIC 4
I tried to test. Created test empty project. CLI asked me, do I want to use Ionic 4?
I asked yes.
Generated page. It was created inside app/ directory, how I think must be
MacBook-Air-Roman:test roman$ ionic generate
? What would you like to generate? page
? Name/path of page: test-page
> ng generate page test-page
CREATE src/app/test-page/test-page.module.ts (554 bytes)
CREATE src/app/test-page/test-page.page.scss (0 bytes)
CREATE src/app/test-page/test-page.page.html (136 bytes)
CREATE src/app/test-page/test-page.page.spec.ts (706 bytes)
CREATE src/app/test-page/test-page.page.ts (267 bytes)
UPDATE src/app/app-routing.module.ts (462 bytes)
[OK] Generated page!
Directive also generated inside app/ folder
MacBook-Air-Roman:test roman$ ionic generate
? What would you like to generate? directive
? Name/path of directive: test-directive
> ng generate directive test-directive
CREATE src/app/test-directive.directive.spec.ts (253 bytes)
CREATE src/app/test-directive.directive.ts (155 bytes)
UPDATE src/app/app.module.ts (856 bytes)
[OK] Generated directive!
IONIC 3
After I created new test project, but on question to use Ionic 4 asked No.
Generated page from project root directory, in my case “test2”
MacBook-Air-Roman:test2 roman$ ionic generate
? What would you like to generate: page
? What should the name be? test-page
[OK] Generated a page named test-page!
Page created inside src/ folder, near app/folder
drwxr-xr-x 7 roman staff 224 Jan 31 18:44 app
drwxr-xr-x 4 roman staff 128 Jan 31 18:44 assets
-rw-r--r-- 1 roman staff 1655 Jan 31 17:41 index.html
-rw-r--r-- 1 roman staff 266 Jan 31 17:41 manifest.json
drwxr-xr-x 4 roman staff 128 Jan 31 18:46 pages
-rw-r--r-- 1 roman staff 741 Jan 31 17:41 service-worker.js
drwxr-xr-x 3 roman staff 96 Jan 31 18:44 theme
Also generated directive, placed near app/ directory, like before with page.
Main questions:
- Is it right with Ionic 3? Maybe if “ionic generate something” place all in src/ folder, don’t touch nothing and trust generator?
- Where from that generator knows which version of Ionic in current project? Because CLI version is 4.8.0, I through ionic version the same too.
- “ionic generate” can not generate validator (custom), so I must create it manually.
Place “validators” folder in src/ folder, like “ionic generate” place folders like pages, directives etc?
Or place inside src/app, like angular way?