01 Ionic Project Structure
01 Ionic Project Structure
App: has all the files needed to bootstrap the app and the main
Assets: in this folder you will find images, sample data json’s, and any
mixins, shared styles, etc) that makes super easy to customize and
Getting started.
Check a getting started file to see how to start developing your app.
You must have your project folder ready before you can read the
following notes.
Adding a new page/screen into the project
By default when you have created a new app, a page called home
page will be created automatically.
{
path: 'about',
loadChildren: () => import('./about/about.module').then( m =>
m.AboutPageModule)
},
{
path: '',
redirectTo: 'home',
pathMatch: 'full'
},
];
@NgModule({
imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
],
exports: [RouterModule]
})
export class AppRoutingModule { }
In this example, we only have one screen and we named it as home.
Check home’s directory.
We have 6 files altogether.
<ion-content class="ion-padding">
<h1>Main Content</h1>
</ion-content>
<ion-footer>
<ion-toolbar color="primary">
<ion-title>Footer</ion-title>
</ion-toolbar>
</ion-footer>
</ion-app>
Result
home-page.scss
#container {
text-align: center;
position: absolute;
left: 0;
right: 0;
top: 50%;
transform: translateY(-50%);
}
#container strong {
font-size: 20px;
line-height: 26px;
}
#container p {
font-size: 16px;
line-height: 22px;
color: #8c8c8c;
margin: 0;
}
#container a {
text-decoration: none;
}
home-page.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
constructor() {}
}
Home-routing.module.ts
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HomePage } from './home.page';
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class HomePageRoutingModule {}