├── .gitignore ├── LICENSE ├── README.md ├── angular.json ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.e2e.json ├── ionic.config.json ├── package.json ├── src ├── app │ ├── add │ │ ├── add.module.ts │ │ ├── add.page.html │ │ ├── add.page.scss │ │ ├── add.page.spec.ts │ │ └── add.page.ts │ ├── api.service.spec.ts │ ├── api.service.ts │ ├── app-routing.module.ts │ ├── app.component.html │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── details │ │ ├── details.module.ts │ │ ├── details.page.html │ │ ├── details.page.scss │ │ ├── details.page.spec.ts │ │ └── details.page.ts │ ├── edit │ │ ├── edit.module.ts │ │ ├── edit.page.html │ │ ├── edit.page.scss │ │ ├── edit.page.spec.ts │ │ └── edit.page.ts │ ├── home │ │ ├── home.module.ts │ │ ├── home.page.html │ │ ├── home.page.scss │ │ ├── home.page.spec.ts │ │ └── home.page.ts │ ├── product.ts │ └── tabs │ │ ├── tabs.module.ts │ │ ├── tabs.page.html │ │ ├── tabs.page.scss │ │ ├── tabs.page.spec.ts │ │ ├── tabs.page.ts │ │ └── tabs.router.module.ts ├── assets │ └── icon │ │ └── favicon.png ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── global.scss ├── index.html ├── karma.conf.js ├── main.ts ├── polyfills.ts ├── test.ts ├── theme │ └── variables.scss ├── tsconfig.app.json └── tsconfig.spec.json ├── tsconfig.json └── tslint.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Specifies intentionally untracked files to ignore when using Git 2 | # http://git-scm.com/docs/gitignore 3 | 4 | *~ 5 | *.sw[mnpcod] 6 | *.log 7 | *.tmp 8 | *.tmp.* 9 | log.txt 10 | *.sublime-project 11 | *.sublime-workspace 12 | .vscode/ 13 | npm-debug.log* 14 | 15 | .idea/ 16 | .ionic/ 17 | .sourcemaps/ 18 | .sass-cache/ 19 | .tmp/ 20 | .versions/ 21 | coverage/ 22 | www/ 23 | node_modules/ 24 | tmp/ 25 | temp/ 26 | platforms/ 27 | plugins/ 28 | plugins/android.json 29 | plugins/ios.json 30 | $RECYCLE.BIN/ 31 | 32 | .DS_Store 33 | Thumbs.db 34 | UserInterfaceState.xcuserstate 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Didin Jamaludin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ionic 4, Angular 7 and Cordova Tutorial: Build CRUD Mobile Apps 2 | 3 | This source code is part of [Ionic 4, Angular 7 and Cordova Tutorial: Build CRUD Mobile Apps](https://www.djamware.com/post/5be52ce280aca72b942e31bc/ionic-4-angular-7-and-cordova-tutorial-build-crud-mobile-apps) tutorial. 4 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json", 3 | "version": 1, 4 | "defaultProject": "app", 5 | "newProjectRoot": "projects", 6 | "projects": { 7 | "app": { 8 | "root": "", 9 | "sourceRoot": "src", 10 | "projectType": "application", 11 | "prefix": "app", 12 | "schematics": {}, 13 | "architect": { 14 | "build": { 15 | "builder": "@angular-devkit/build-angular:browser", 16 | "options": { 17 | "progress": false, 18 | "outputPath": "www", 19 | "index": "src/index.html", 20 | "main": "src/main.ts", 21 | "polyfills": "src/polyfills.ts", 22 | "tsConfig": "src/tsconfig.app.json", 23 | "assets": [ 24 | { 25 | "glob": "**/*", 26 | "input": "src/assets", 27 | "output": "assets" 28 | }, 29 | { 30 | "glob": "**/*.svg", 31 | "input": "node_modules/@ionic/angular/dist/ionic/svg", 32 | "output": "./svg" 33 | } 34 | ], 35 | "styles": [ 36 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 37 | { 38 | "input": "src/theme/variables.scss" 39 | }, 40 | { 41 | "input": "src/global.scss" 42 | } 43 | ], 44 | "scripts": [] 45 | }, 46 | "configurations": { 47 | "production": { 48 | "fileReplacements": [ 49 | { 50 | "replace": "src/environments/environment.ts", 51 | "with": "src/environments/environment.prod.ts" 52 | } 53 | ], 54 | "optimization": true, 55 | "outputHashing": "all", 56 | "sourceMap": false, 57 | "extractCss": true, 58 | "namedChunks": false, 59 | "aot": true, 60 | "extractLicenses": true, 61 | "vendorChunk": false, 62 | "buildOptimizer": true 63 | } 64 | } 65 | }, 66 | "serve": { 67 | "builder": "@angular-devkit/build-angular:dev-server", 68 | "options": { 69 | "browserTarget": "app:build" 70 | }, 71 | "configurations": { 72 | "production": { 73 | "browserTarget": "app:build:production" 74 | } 75 | } 76 | }, 77 | "extract-i18n": { 78 | "builder": "@angular-devkit/build-angular:extract-i18n", 79 | "options": { 80 | "browserTarget": "app:build" 81 | } 82 | }, 83 | "test": { 84 | "builder": "@angular-devkit/build-angular:karma", 85 | "options": { 86 | "main": "src/test.ts", 87 | "polyfills": "src/polyfills.ts", 88 | "tsConfig": "src/tsconfig.spec.json", 89 | "karmaConfig": "src/karma.conf.js", 90 | "styles": [ 91 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css" 92 | ], 93 | "scripts": [], 94 | "assets": [ 95 | { 96 | "glob": "favicon.ico", 97 | "input": "src/", 98 | "output": "/" 99 | }, 100 | { 101 | "glob": "**/*", 102 | "input": "src/assets", 103 | "output": "/assets" 104 | } 105 | ] 106 | } 107 | }, 108 | "lint": { 109 | "builder": "@angular-devkit/build-angular:tslint", 110 | "options": { 111 | "tsConfig": [ 112 | "src/tsconfig.app.json", 113 | "src/tsconfig.spec.json" 114 | ], 115 | "exclude": [ 116 | "**/node_modules/**" 117 | ] 118 | } 119 | }, 120 | "ionic-cordova-build": { 121 | "builder": "@ionic/angular-toolkit:cordova-build", 122 | "options": { 123 | "browserTarget": "app:build" 124 | }, 125 | "configurations": { 126 | "production": { 127 | "browserTarget": "app:build:production" 128 | } 129 | } 130 | }, 131 | "ionic-cordova-serve": { 132 | "builder": "@ionic/angular-toolkit:cordova-serve", 133 | "options": { 134 | "cordovaBuildTarget": "app:ionic-cordova-build", 135 | "devServerTarget": "app:serve" 136 | }, 137 | "configurations": { 138 | "production": { 139 | "cordovaBuildTarget": "app:ionic-cordova-build:production", 140 | "devServerTarget": "app:serve:production" 141 | } 142 | } 143 | } 144 | } 145 | }, 146 | "app-e2e": { 147 | "root": "e2e/", 148 | "projectType": "application", 149 | "architect": { 150 | "e2e": { 151 | "builder": "@angular-devkit/build-angular:protractor", 152 | "options": { 153 | "protractorConfig": "e2e/protractor.conf.js", 154 | "devServerTarget": "app:serve" 155 | } 156 | }, 157 | "lint": { 158 | "builder": "@angular-devkit/build-angular:tslint", 159 | "options": { 160 | "tsConfig": "e2e/tsconfig.e2e.json", 161 | "exclude": [ 162 | "**/node_modules/**" 163 | ] 164 | } 165 | } 166 | } 167 | } 168 | }, 169 | "cli": { 170 | "defaultCollection": "@ionic/angular-toolkit" 171 | }, 172 | "schematics": { 173 | "@ionic/angular-toolkit:component": { 174 | "styleext": "scss" 175 | }, 176 | "@ionic/angular-toolkit:page": { 177 | "styleext": "scss" 178 | } 179 | } 180 | } -------------------------------------------------------------------------------- /e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: 'e2e/tsconfig.e2e.json' 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('new App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toContain('The world is your oyster.'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.deepCss('app-root ion-content')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/e2e", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "target": "es5" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ionic.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ionic4-angular7-crud", 3 | "integrations": {}, 4 | "type": "angular" 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ionic4-angular7-crud", 3 | "version": "0.0.1", 4 | "author": "Ionic Framework", 5 | "homepage": "http://ionicframework.com/", 6 | "scripts": { 7 | "ng": "ng", 8 | "start": "ng serve", 9 | "build": "ng build", 10 | "test": "ng test", 11 | "lint": "ng lint", 12 | "e2e": "ng e2e" 13 | }, 14 | "private": true, 15 | "dependencies": { 16 | "@angular/animations": "^7.0.3", 17 | "@angular/cdk": "^7.2.1", 18 | "@angular/common": "^7.0.3", 19 | "@angular/core": "^7.0.3", 20 | "@angular/forms": "^7.0.3", 21 | "@angular/http": "^7.0.3", 22 | "@angular/material": "^7.2.1", 23 | "@angular/platform-browser": "^7.0.3", 24 | "@angular/platform-browser-dynamic": "^7.0.3", 25 | "@angular/router": "^7.0.3", 26 | "@ionic-native/core": "5.0.0-beta.21", 27 | "@ionic-native/splash-screen": "5.0.0-beta.21", 28 | "@ionic-native/status-bar": "5.0.0-beta.21", 29 | "@ionic/angular": "4.0.0-beta.15", 30 | "core-js": "^2.5.3", 31 | "hammerjs": "^2.0.8", 32 | "rxjs": "6.2.2", 33 | "zone.js": "^0.8.26" 34 | }, 35 | "devDependencies": { 36 | "@angular-devkit/architect": "^0.10.4", 37 | "@angular-devkit/build-angular": "^0.12.0", 38 | "@angular-devkit/core": "^7.0.4", 39 | "@angular-devkit/schematics": "^7.0.4", 40 | "@angular/cli": "^7.0.4", 41 | "@angular/compiler": "^7.0.3", 42 | "@angular/compiler-cli": "^7.0.3", 43 | "@angular/language-service": "^7.0.3", 44 | "@ionic/angular-toolkit": "^1.0.0", 45 | "@ionic/lab": "^1.0.13", 46 | "@types/jasmine": "^2.8.11", 47 | "@types/jasminewd2": "^2.0.6", 48 | "@types/node": "^10.12.3", 49 | "codelyzer": "~4.5.0", 50 | "jasmine-core": "~2.99.1", 51 | "jasmine-spec-reporter": "~4.2.1", 52 | "karma": "~3.0.0", 53 | "karma-chrome-launcher": "~2.2.0", 54 | "karma-coverage-istanbul-reporter": "~2.0.0", 55 | "karma-jasmine": "~1.1.1", 56 | "karma-jasmine-html-reporter": "^0.2.2", 57 | "protractor": "~5.4.0", 58 | "ts-node": "~7.0.0", 59 | "tslint": "~5.11.0", 60 | "typescript": "^3.1.6" 61 | }, 62 | "description": "An Ionic project" 63 | } 64 | -------------------------------------------------------------------------------- /src/app/add/add.module.ts: -------------------------------------------------------------------------------- 1 | import { IonicModule } from '@ionic/angular'; 2 | import { RouterModule } from '@angular/router'; 3 | import { NgModule } from '@angular/core'; 4 | import { CommonModule } from '@angular/common'; 5 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; 6 | import { AddPage } from './add.page'; 7 | 8 | @NgModule({ 9 | imports: [ 10 | IonicModule, 11 | CommonModule, 12 | FormsModule, 13 | ReactiveFormsModule, 14 | RouterModule.forChild([{ path: '', component: AddPage }]) 15 | ], 16 | declarations: [AddPage] 17 | }) 18 | export class AddPageModule {} 19 | -------------------------------------------------------------------------------- /src/app/add/add.page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Add Product 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | Product Name 13 | 14 | 15 | 16 | Product Price 17 | 18 | 19 | 20 | Product Description 21 | 22 | 23 | Submit 24 |
25 |
26 | -------------------------------------------------------------------------------- /src/app/add/add.page.scss: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/app/add/add.page.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | 4 | import { AddPage } from './add.page'; 5 | 6 | describe('AddPage', () => { 7 | let component: AddPage; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [AddPage], 13 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 14 | }).compileComponents(); 15 | })); 16 | 17 | beforeEach(() => { 18 | fixture = TestBed.createComponent(AddPage); 19 | component = fixture.componentInstance; 20 | fixture.detectChanges(); 21 | }); 22 | 23 | it('should create', () => { 24 | expect(component).toBeTruthy(); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /src/app/add/add.page.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { LoadingController, AlertController } from '@ionic/angular'; 3 | import { ApiService } from '../api.service'; 4 | import { ActivatedRoute, Router } from '@angular/router'; 5 | import { FormControl, FormGroupDirective, FormBuilder, FormGroup, NgForm, Validators } from '@angular/forms'; 6 | import { Product } from '../product'; 7 | 8 | @Component({ 9 | selector: 'app-add', 10 | templateUrl: 'add.page.html', 11 | styleUrls: ['add.page.scss'] 12 | }) 13 | export class AddPage { 14 | 15 | productForm: FormGroup; 16 | prod_name:string=''; 17 | prod_desc:string=''; 18 | prod_price:number=null; 19 | 20 | constructor(public api: ApiService, 21 | public loadingController: LoadingController, 22 | public alertController: AlertController, 23 | public route: ActivatedRoute, 24 | public router: Router, 25 | private formBuilder: FormBuilder) { 26 | } 27 | 28 | ngOnInit() { 29 | this.productForm = this.formBuilder.group({ 30 | 'prod_name' : [null, Validators.required], 31 | 'prod_desc' : [null, Validators.required], 32 | 'prod_price' : [null, Validators.required] 33 | }); 34 | } 35 | 36 | async onFormSubmit(form:NgForm) { 37 | const loading = await this.loadingController.create({ 38 | message: 'Loading...' 39 | }); 40 | await loading.present(); 41 | await this.api.addProduct(form) 42 | .subscribe(res => { 43 | let id = res['_id']; 44 | loading.dismiss(); 45 | console.log(this.router); 46 | this.router.navigate([ { outlets: { details: id } } ], { relativeTo: this.route.parent }); 47 | }, (err) => { 48 | console.log(err); 49 | loading.dismiss(); 50 | }); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/app/api.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { ApiService } from './api.service'; 4 | 5 | describe('ApiService', () => { 6 | beforeEach(() => TestBed.configureTestingModule({})); 7 | 8 | it('should be created', () => { 9 | const service: ApiService = TestBed.get(ApiService); 10 | expect(service).toBeTruthy(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/app/api.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Observable, of, throwError } from 'rxjs'; 3 | import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http'; 4 | import { catchError, tap, map } from 'rxjs/operators'; 5 | import { Product } from './product'; 6 | 7 | const httpOptions = { 8 | headers: new HttpHeaders({'Content-Type': 'application/json'}) 9 | }; 10 | const apiUrl = "http://localhost:3000/api/v1/products"; 11 | 12 | @Injectable({ 13 | providedIn: 'root' 14 | }) 15 | export class ApiService { 16 | 17 | constructor(private http: HttpClient) { } 18 | 19 | private handleError (operation = 'operation', result?: T) { 20 | return (error: any): Observable => { 21 | 22 | // TODO: send the error to remote logging infrastructure 23 | console.error(error); // log to console instead 24 | 25 | // Let the app keep running by returning an empty result. 26 | return of(result as T); 27 | }; 28 | } 29 | 30 | getProducts (): Observable { 31 | return this.http.get(apiUrl) 32 | .pipe( 33 | tap(heroes => console.log('fetched products')), 34 | catchError(this.handleError('getProducts', [])) 35 | ); 36 | } 37 | 38 | getProduct(id): Observable { 39 | const url = `${apiUrl}/${id}`; 40 | return this.http.get(url).pipe( 41 | tap(_ => console.log(`fetched product id=${id}`)), 42 | catchError(this.handleError(`getProduct id=${id}`)) 43 | ); 44 | } 45 | 46 | addProduct (product): Observable { 47 | return this.http.post(apiUrl, product, httpOptions).pipe( 48 | tap((product: Product) => console.log(`added product w/ id=${product._id}`)), 49 | catchError(this.handleError('addProduct')) 50 | ); 51 | } 52 | 53 | updateProduct (id, product): Observable { 54 | const url = `${apiUrl}/${id}`; 55 | return this.http.put(url, product, httpOptions).pipe( 56 | tap(_ => console.log(`updated product id=${id}`)), 57 | catchError(this.handleError('updateProduct')) 58 | ); 59 | } 60 | 61 | deleteProduct (id): Observable { 62 | const url = `${apiUrl}/${id}`; 63 | 64 | return this.http.delete(url, httpOptions).pipe( 65 | tap(_ => console.log(`deleted product id=${id}`)), 66 | catchError(this.handleError('deleteProduct')) 67 | ); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | 4 | const routes: Routes = [ 5 | { path: '', loadChildren: './tabs/tabs.module#TabsPageModule' }, 6 | { path: 'details', loadChildren: './details/details.module#DetailsPageModule' } 7 | ]; 8 | @NgModule({ 9 | imports: [RouterModule.forRoot(routes)], 10 | exports: [RouterModule] 11 | }) 12 | export class AppRoutingModule {} 13 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { TestBed, async } from '@angular/core/testing'; 3 | 4 | import { Platform } from '@ionic/angular'; 5 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 6 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 7 | 8 | import { AppComponent } from './app.component'; 9 | 10 | describe('AppComponent', () => { 11 | 12 | let statusBarSpy, splashScreenSpy, platformReadySpy, platformSpy; 13 | 14 | beforeEach(async(() => { 15 | statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']); 16 | splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']); 17 | platformReadySpy = Promise.resolve(); 18 | platformSpy = jasmine.createSpyObj('Platform', { ready: platformReadySpy }); 19 | 20 | TestBed.configureTestingModule({ 21 | declarations: [AppComponent], 22 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 23 | providers: [ 24 | { provide: StatusBar, useValue: statusBarSpy }, 25 | { provide: SplashScreen, useValue: splashScreenSpy }, 26 | { provide: Platform, useValue: platformSpy }, 27 | ], 28 | }).compileComponents(); 29 | })); 30 | 31 | it('should create the app', () => { 32 | const fixture = TestBed.createComponent(AppComponent); 33 | const app = fixture.debugElement.componentInstance; 34 | expect(app).toBeTruthy(); 35 | }); 36 | 37 | it('should initialize the app', async () => { 38 | TestBed.createComponent(AppComponent); 39 | expect(platformSpy.ready).toHaveBeenCalled(); 40 | await platformReadySpy; 41 | expect(statusBarSpy.styleDefault).toHaveBeenCalled(); 42 | expect(splashScreenSpy.hide).toHaveBeenCalled(); 43 | }); 44 | 45 | // TODO: add more tests! 46 | 47 | }); 48 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | import { Platform } from '@ionic/angular'; 4 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 5 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 6 | 7 | @Component({ 8 | selector: 'app-root', 9 | templateUrl: 'app.component.html' 10 | }) 11 | export class AppComponent { 12 | constructor( 13 | private platform: Platform, 14 | private splashScreen: SplashScreen, 15 | private statusBar: StatusBar 16 | ) { 17 | this.initializeApp(); 18 | } 19 | 20 | initializeApp() { 21 | this.platform.ready().then(() => { 22 | this.statusBar.styleDefault(); 23 | this.splashScreen.hide(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { RouteReuseStrategy } from '@angular/router'; 4 | import { HttpClientModule } from '@angular/common/http'; 5 | 6 | import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; 7 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 8 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 9 | 10 | import { AppRoutingModule } from './app-routing.module'; 11 | import { AppComponent } from './app.component'; 12 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 13 | import { 14 | MatInputModule, 15 | MatPaginatorModule, 16 | MatProgressSpinnerModule, 17 | MatSortModule, 18 | MatTableModule, 19 | MatIconModule, 20 | MatButtonModule, 21 | MatCardModule, 22 | MatFormFieldModule } from "@angular/material"; 23 | 24 | @NgModule({ 25 | declarations: [AppComponent], 26 | entryComponents: [], 27 | imports: [ 28 | BrowserModule, 29 | HttpClientModule, 30 | IonicModule.forRoot(), 31 | AppRoutingModule, 32 | BrowserAnimationsModule, 33 | MatInputModule, 34 | MatPaginatorModule, 35 | MatProgressSpinnerModule, 36 | MatSortModule, 37 | MatTableModule, 38 | MatIconModule, 39 | MatButtonModule, 40 | MatCardModule, 41 | MatFormFieldModule 42 | ], 43 | providers: [ 44 | StatusBar, 45 | SplashScreen, 46 | { provide: RouteReuseStrategy, useClass: IonicRouteStrategy } 47 | ], 48 | bootstrap: [AppComponent] 49 | }) 50 | export class AppModule {} 51 | -------------------------------------------------------------------------------- /src/app/details/details.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { Routes, RouterModule } from '@angular/router'; 5 | 6 | import { IonicModule } from '@ionic/angular'; 7 | 8 | import { DetailsPage } from './details.page'; 9 | 10 | const routes: Routes = [ 11 | { 12 | path: '', 13 | component: DetailsPage 14 | } 15 | ]; 16 | 17 | @NgModule({ 18 | imports: [ 19 | CommonModule, 20 | FormsModule, 21 | IonicModule, 22 | RouterModule.forChild(routes) 23 | ], 24 | declarations: [DetailsPage] 25 | }) 26 | export class DetailsPageModule {} 27 | -------------------------------------------------------------------------------- /src/app/details/details.page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Details 4 | 5 | 6 | 7 | 8 | 9 | 10 | {{product.prod_name}} 11 | 12 | 13 | 14 | 15 |

Price:

16 |

{{product.prod_price | currency}}

17 |
18 | 19 |

Description:

20 |

{{product.prod_desc}}

21 |
22 | Edit 23 | Delete 24 |
25 |
26 |
27 | -------------------------------------------------------------------------------- /src/app/details/details.page.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/didinj/ionic4-angular7-example/492558827fe2d8e6246e3f16173141a262ba1cac/src/app/details/details.page.scss -------------------------------------------------------------------------------- /src/app/details/details.page.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | 4 | import { DetailsPage } from './details.page'; 5 | 6 | describe('DetailsPage', () => { 7 | let component: DetailsPage; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [ DetailsPage ], 13 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 14 | }) 15 | .compileComponents(); 16 | })); 17 | 18 | beforeEach(() => { 19 | fixture = TestBed.createComponent(DetailsPage); 20 | component = fixture.componentInstance; 21 | fixture.detectChanges(); 22 | }); 23 | 24 | it('should create', () => { 25 | expect(component).toBeTruthy(); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /src/app/details/details.page.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { LoadingController, AlertController } from '@ionic/angular'; 3 | import { ApiService } from '../api.service'; 4 | import { ActivatedRoute, Router } from '@angular/router'; 5 | import { Product } from '../product'; 6 | 7 | @Component({ 8 | selector: 'app-details', 9 | templateUrl: './details.page.html', 10 | styleUrls: ['./details.page.scss'], 11 | }) 12 | export class DetailsPage implements OnInit { 13 | 14 | product:Product = { _id: null, prod_name: '', prod_desc: '', prod_price: null, updated_at: null }; 15 | 16 | constructor(public api: ApiService, 17 | public loadingController: LoadingController, 18 | public alertController: AlertController, 19 | public route: ActivatedRoute, 20 | public router: Router) {} 21 | 22 | ngOnInit() { 23 | this.getProduct(); 24 | } 25 | 26 | async getProduct() { 27 | if(this.route.snapshot.paramMap.get('id') == 'null') { 28 | this.presentAlertConfirm('You are not choosing an item from the list'); 29 | } else { 30 | const loading = await this.loadingController.create({ 31 | message: 'Loading...' 32 | }); 33 | await loading.present(); 34 | await this.api.getProduct(this.route.snapshot.paramMap.get('id')) 35 | .subscribe(res => { 36 | console.log(res); 37 | this.product = res; 38 | loading.dismiss(); 39 | }, err => { 40 | console.log(err); 41 | loading.dismiss(); 42 | }); 43 | } 44 | } 45 | 46 | async delete(id) { 47 | const loading = await this.loadingController.create({ 48 | message: 'Loading...' 49 | }); 50 | await loading.present(); 51 | await this.api.deleteProduct(id) 52 | .subscribe(res => { 53 | loading.dismiss(); 54 | this.router.navigate([ '/tabs', { outlets: { home: 'home' } } ]); 55 | }, err => { 56 | console.log(err); 57 | loading.dismiss(); 58 | }); 59 | } 60 | 61 | async presentAlertConfirm(msg: string) { 62 | const alert = await this.alertController.create({ 63 | header: 'Warning!', 64 | message: msg, 65 | buttons: [ 66 | { 67 | text: 'Okay', 68 | handler: () => { 69 | this.router.navigate(['']); 70 | } 71 | } 72 | ] 73 | }); 74 | 75 | await alert.present(); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/app/edit/edit.module.ts: -------------------------------------------------------------------------------- 1 | import { IonicModule } from '@ionic/angular'; 2 | import { RouterModule } from '@angular/router'; 3 | import { NgModule } from '@angular/core'; 4 | import { CommonModule } from '@angular/common'; 5 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; 6 | import { EditPage } from './edit.page'; 7 | 8 | @NgModule({ 9 | imports: [ 10 | IonicModule, 11 | CommonModule, 12 | FormsModule, 13 | ReactiveFormsModule, 14 | RouterModule.forChild([{ path: '', component: EditPage }]) 15 | ], 16 | declarations: [EditPage] 17 | }) 18 | export class EditPageModule {} 19 | -------------------------------------------------------------------------------- /src/app/edit/edit.page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Edit 4 | 5 | 6 | 7 | 8 |
9 | 10 | Product Name 11 | 12 | 13 | 14 | Product Price 15 | 16 | 17 | 18 | Product Description 19 | 20 | 21 | Submit 22 |
23 |
24 | -------------------------------------------------------------------------------- /src/app/edit/edit.page.scss: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/app/edit/edit.page.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | 4 | import { EditPage } from './edit.page'; 5 | 6 | describe('EditPage', () => { 7 | let component: EditPage; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [EditPage], 13 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 14 | }).compileComponents(); 15 | })); 16 | 17 | beforeEach(() => { 18 | fixture = TestBed.createComponent(EditPage); 19 | component = fixture.componentInstance; 20 | fixture.detectChanges(); 21 | }); 22 | 23 | it('should create', () => { 24 | expect(component).toBeTruthy(); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /src/app/edit/edit.page.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { LoadingController, AlertController } from '@ionic/angular'; 3 | import { ApiService } from '../api.service'; 4 | import { ActivatedRoute, Router } from '@angular/router'; 5 | import { FormControl, FormGroupDirective, FormBuilder, FormGroup, NgForm, Validators } from '@angular/forms'; 6 | import { Product } from '../product'; 7 | 8 | @Component({ 9 | selector: 'app-edit', 10 | templateUrl: 'edit.page.html', 11 | styleUrls: ['edit.page.scss'] 12 | }) 13 | export class EditPage { 14 | 15 | productForm: FormGroup; 16 | _id:any=''; 17 | prod_name:string=''; 18 | prod_desc:string=''; 19 | prod_price:number=null; 20 | 21 | constructor(public api: ApiService, 22 | public loadingController: LoadingController, 23 | public alertController: AlertController, 24 | public route: ActivatedRoute, 25 | public router: Router, 26 | private formBuilder: FormBuilder) { 27 | } 28 | 29 | ngOnInit() { 30 | this.getProduct(this.route.snapshot.params['id']); 31 | this.productForm = this.formBuilder.group({ 32 | 'prod_name' : [null, Validators.required], 33 | 'prod_desc' : [null, Validators.required], 34 | 'prod_price' : [null, Validators.required] 35 | }); 36 | } 37 | 38 | async getProduct(id) { 39 | if(this.route.snapshot.paramMap.get('id') == 'null') { 40 | this.presentAlertConfirm('You are not choosing an item from the list'); 41 | } else { 42 | const loading = await this.loadingController.create({ 43 | message: 'Loading...' 44 | }); 45 | await loading.present(); 46 | await this.api.getProduct(id) 47 | .subscribe(data => { 48 | this._id = data._id; 49 | this.productForm.setValue({ 50 | prod_name: data.prod_name, 51 | prod_desc: data.prod_desc, 52 | prod_price: data.prod_price 53 | }); 54 | loading.dismiss(); 55 | }, err => { 56 | console.log(err); 57 | loading.dismiss(); 58 | }); 59 | } 60 | } 61 | 62 | async onFormSubmit(form:NgForm) { 63 | await this.api.updateProduct(this._id, form) 64 | .subscribe(res => { 65 | let id = res['_id']; 66 | this.router.navigate([ '/tabs', { outlets: { details: id }} ]); 67 | }, (err) => { 68 | console.log(err); 69 | } 70 | ); 71 | } 72 | 73 | async presentAlertConfirm(msg: string) { 74 | const alert = await this.alertController.create({ 75 | header: 'Warning!', 76 | message: msg, 77 | buttons: [ 78 | { 79 | text: 'Okay', 80 | handler: () => { 81 | this.router.navigate(['']); 82 | } 83 | } 84 | ] 85 | }); 86 | 87 | await alert.present(); 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /src/app/home/home.module.ts: -------------------------------------------------------------------------------- 1 | import { IonicModule } from '@ionic/angular'; 2 | import { RouterModule } from '@angular/router'; 3 | import { NgModule } from '@angular/core'; 4 | import { CommonModule } from '@angular/common'; 5 | import { FormsModule } from '@angular/forms'; 6 | import { ScrollingModule } from '@angular/cdk/scrolling'; 7 | import { DragDropModule } from '@angular/cdk/drag-drop'; 8 | import { HomePage } from './home.page'; 9 | 10 | @NgModule({ 11 | imports: [ 12 | IonicModule, 13 | CommonModule, 14 | FormsModule, 15 | ScrollingModule, 16 | DragDropModule, 17 | RouterModule.forChild([{ path: '', component: HomePage }]) 18 | ], 19 | declarations: [HomePage] 20 | }) 21 | export class HomePageModule {} 22 | -------------------------------------------------------------------------------- /src/app/home/home.page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Home 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | {{p.prod_name}} 12 |
13 | {{p.prod_price | currency}} 14 |
15 |
16 |
17 |
18 | -------------------------------------------------------------------------------- /src/app/home/home.page.scss: -------------------------------------------------------------------------------- 1 | .example-viewport { 2 | height: 100%; 3 | width: 100%; 4 | border: 1px solid black; 5 | background: white; 6 | border: solid 1px #999; 7 | } 8 | .example-item { 9 | height: 50px; 10 | padding: 5px 10px; 11 | } 12 | -------------------------------------------------------------------------------- /src/app/home/home.page.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | 4 | import { HomePage } from './home.page'; 5 | 6 | describe('HomePage', () => { 7 | let component: HomePage; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [HomePage], 13 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 14 | }).compileComponents(); 15 | })); 16 | 17 | beforeEach(() => { 18 | fixture = TestBed.createComponent(HomePage); 19 | component = fixture.componentInstance; 20 | fixture.detectChanges(); 21 | }); 22 | 23 | it('should create', () => { 24 | expect(component).toBeTruthy(); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /src/app/home/home.page.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { LoadingController } from '@ionic/angular'; 3 | import { ActivatedRoute, Router } from '@angular/router'; 4 | import { ApiService } from '../api.service'; 5 | import { Product } from '../product'; 6 | import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; 7 | 8 | @Component({ 9 | selector: 'app-home', 10 | templateUrl: 'home.page.html', 11 | styleUrls: ['home.page.scss'] 12 | }) 13 | export class HomePage { 14 | 15 | products: Product[] = []; 16 | 17 | constructor(public api: ApiService, 18 | public loadingController: LoadingController, 19 | public router: Router, 20 | public route: ActivatedRoute) { } 21 | 22 | ngOnInit() { 23 | this.getProducts(); 24 | } 25 | 26 | async getProducts() { 27 | const loading = await this.loadingController.create({ 28 | message: 'Loading...' 29 | }); 30 | await loading.present(); 31 | await this.api.getProducts() 32 | .subscribe(res => { 33 | this.products = res; 34 | console.log(this.products); 35 | loading.dismiss(); 36 | }, err => { 37 | console.log(err); 38 | loading.dismiss(); 39 | }); 40 | } 41 | 42 | drop(event: CdkDragDrop) { 43 | moveItemInArray(this.products, event.previousIndex, event.currentIndex); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/app/product.ts: -------------------------------------------------------------------------------- 1 | export class Product { 2 | _id: number; 3 | prod_name: string; 4 | prod_desc: string; 5 | prod_price: number; 6 | updated_at: Date; 7 | } 8 | -------------------------------------------------------------------------------- /src/app/tabs/tabs.module.ts: -------------------------------------------------------------------------------- 1 | import { IonicModule } from '@ionic/angular'; 2 | import { RouterModule } from '@angular/router'; 3 | import { NgModule } from '@angular/core'; 4 | import { CommonModule } from '@angular/common'; 5 | import { FormsModule } from '@angular/forms'; 6 | 7 | import { TabsPageRoutingModule } from './tabs.router.module'; 8 | 9 | import { TabsPage } from './tabs.page'; 10 | import { AddPageModule } from '../add/add.module'; 11 | import { EditPageModule } from '../edit/edit.module'; 12 | import { HomePageModule } from '../home/home.module'; 13 | import { DetailsPageModule } from '../details/details.module'; 14 | 15 | @NgModule({ 16 | imports: [ 17 | IonicModule, 18 | CommonModule, 19 | FormsModule, 20 | TabsPageRoutingModule, 21 | HomePageModule, 22 | AddPageModule, 23 | EditPageModule, 24 | DetailsPageModule 25 | ], 26 | declarations: [TabsPage] 27 | }) 28 | export class TabsPageModule {} 29 | -------------------------------------------------------------------------------- /src/app/tabs/tabs.page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Home 21 | 22 | 23 | 24 | 25 | Details 26 | 27 | 28 | 29 | 30 | Add 31 | 32 | 33 | 34 | 35 | Edit 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/app/tabs/tabs.page.scss: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/app/tabs/tabs.page.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | 4 | import { TabsPage } from './tabs.page'; 5 | 6 | describe('TabsPage', () => { 7 | let component: TabsPage; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [TabsPage], 13 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 14 | }).compileComponents(); 15 | })); 16 | 17 | beforeEach(() => { 18 | fixture = TestBed.createComponent(TabsPage); 19 | component = fixture.componentInstance; 20 | fixture.detectChanges(); 21 | }); 22 | 23 | it('should create', () => { 24 | expect(component).toBeTruthy(); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /src/app/tabs/tabs.page.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-tabs', 5 | templateUrl: 'tabs.page.html', 6 | styleUrls: ['tabs.page.scss'] 7 | }) 8 | export class TabsPage {} 9 | -------------------------------------------------------------------------------- /src/app/tabs/tabs.router.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | 4 | import { TabsPage } from './tabs.page'; 5 | import { HomePage } from '../home/home.page'; 6 | import { AddPage } from '../add/add.page'; 7 | import { EditPage } from '../edit/edit.page'; 8 | import { DetailsPage } from '../details/details.page'; 9 | 10 | const routes: Routes = [ 11 | { 12 | path: 'tabs', 13 | component: TabsPage, 14 | children: [ 15 | { 16 | path: '', 17 | redirectTo: '/tabs/(home:home)', 18 | pathMatch: 'full', 19 | }, 20 | { 21 | path: 'home', 22 | outlet: 'home', 23 | component: HomePage 24 | }, 25 | { 26 | path: 'add', 27 | outlet: 'add', 28 | component: AddPage 29 | }, 30 | { 31 | path: ':id', 32 | outlet: 'edit', 33 | component: EditPage 34 | }, 35 | { 36 | path: ':id', 37 | outlet: 'details', 38 | component: DetailsPage 39 | } 40 | ] 41 | }, 42 | { 43 | path: '', 44 | redirectTo: '/tabs/(home:home)', 45 | pathMatch: 'full' 46 | } 47 | ]; 48 | 49 | @NgModule({ 50 | imports: [RouterModule.forChild(routes)], 51 | exports: [RouterModule] 52 | }) 53 | export class TabsPageRoutingModule {} 54 | -------------------------------------------------------------------------------- /src/assets/icon/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/didinj/ionic4-angular7-example/492558827fe2d8e6246e3f16173141a262ba1cac/src/assets/icon/favicon.png -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // The file contents for the current environment will overwrite these during build. 2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 4 | // The list of which env maps to which file can be found in `.angular-cli.json`. 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * In development mode, to ignore zone related error stack frames such as 11 | * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can 12 | * import the following file, but please comment it out in production mode 13 | * because it will have performance impact when throw error 14 | */ 15 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 16 | -------------------------------------------------------------------------------- /src/global.scss: -------------------------------------------------------------------------------- 1 | // http://ionicframework.com/docs/theming/ 2 | @import "~@ionic/angular/css/core.css"; 3 | @import "~@ionic/angular/css/normalize.css"; 4 | @import "~@ionic/angular/css/structure.css"; 5 | @import "~@ionic/angular/css/typography.css"; 6 | 7 | @import "~@ionic/angular/css/padding.css"; 8 | @import "~@ionic/angular/css/float-elements.css"; 9 | @import "~@ionic/angular/css/text-alignment.css"; 10 | @import "~@ionic/angular/css/text-transformation.css"; 11 | @import "~@ionic/angular/css/flex-utils.css"; 12 | 13 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ionic App 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage'), 20 | reports: ['html', 'lcovonly'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import 'hammerjs'; 2 | import { enableProdMode } from '@angular/core'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | import { AppModule } from './app/app.module'; 6 | import { environment } from './environments/environment'; 7 | 8 | if (environment.production) { 9 | enableProdMode(); 10 | } 11 | 12 | platformBrowserDynamic().bootstrapModule(AppModule) 13 | .catch(err => console.log(err)); 14 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/regexp'; 32 | // import 'core-js/es6/map'; 33 | // import 'core-js/es6/weak-map'; 34 | // import 'core-js/es6/set'; 35 | 36 | /** 37 | * If your app need to indexed by Google Search, your app require polyfills 'core-js/es6/array' 38 | * Google bot use ES5. 39 | * FYI: Googlebot uses a renderer following the similar spec to Chrome 41. 40 | * https://developers.google.com/search/docs/guides/rendering 41 | **/ 42 | // import 'core-js/es6/array'; 43 | 44 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 45 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 46 | 47 | /** IE10 and IE11 requires the following for the Reflect API. */ 48 | // import 'core-js/es6/reflect'; 49 | 50 | 51 | /** Evergreen browsers require these. **/ 52 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. 53 | import 'core-js/es7/reflect'; 54 | 55 | 56 | /** 57 | * Web Animations `@angular/platform-browser/animations` 58 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 59 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 60 | **/ 61 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 62 | 63 | /** 64 | * By default, zone.js will patch all possible macroTask and DomEvents 65 | * user can disable parts of macroTask/DomEvents patch by setting following flags 66 | */ 67 | 68 | // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 69 | // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 70 | // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 71 | 72 | /* 73 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 74 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 75 | */ 76 | // (window as any).__Zone_enable_cross_context_check = true; 77 | 78 | /*************************************************************************************************** 79 | * Zone JS is required by default for Angular itself. 80 | */ 81 | import 'zone.js/dist/zone'; // Included with Angular CLI. 82 | 83 | 84 | 85 | /*************************************************************************************************** 86 | * APPLICATION IMPORTS 87 | */ 88 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /src/theme/variables.scss: -------------------------------------------------------------------------------- 1 | // Ionic Variables and Theming. For more info, please see: 2 | // http://ionicframework.com/docs/theming/ 3 | 4 | /** Ionic CSS Variables **/ 5 | :root { 6 | 7 | /** primary **/ 8 | --ion-color-primary: #3880ff; 9 | --ion-color-primary-rgb: 56,128,255; 10 | --ion-color-primary-contrast: #ffffff; 11 | --ion-color-primary-contrast-rgb: 255,255,255; 12 | --ion-color-primary-shade: #3171e0; 13 | --ion-color-primary-tint: #4c8dff; 14 | 15 | /** secondary **/ 16 | --ion-color-secondary: #0cd1e8; 17 | --ion-color-secondary-rgb: 12,209,232; 18 | --ion-color-secondary-contrast: #ffffff; 19 | --ion-color-secondary-contrast-rgb: 255,255,255; 20 | --ion-color-secondary-shade: #0bb8cc; 21 | --ion-color-secondary-tint: #24d6ea; 22 | 23 | /** tertiary **/ 24 | --ion-color-tertiary: #7044ff; 25 | --ion-color-tertiary-rgb: 112,68,255; 26 | --ion-color-tertiary-contrast: #ffffff; 27 | --ion-color-tertiary-contrast-rgb: 255,255,255; 28 | --ion-color-tertiary-shade: #633ce0; 29 | --ion-color-tertiary-tint: #7e57ff; 30 | 31 | /** success **/ 32 | --ion-color-success: #10dc60; 33 | --ion-color-success-rgb: 16,220,96; 34 | --ion-color-success-contrast: #ffffff; 35 | --ion-color-success-contrast-rgb: 255,255,255; 36 | --ion-color-success-shade: #0ec254; 37 | --ion-color-success-tint: #28e070; 38 | 39 | /** warning **/ 40 | --ion-color-warning: #ffce00; 41 | --ion-color-warning-rgb: 255,206,0; 42 | --ion-color-warning-contrast: #ffffff; 43 | --ion-color-warning-contrast-rgb: 255,255,255; 44 | --ion-color-warning-shade: #e0b500; 45 | --ion-color-warning-tint: #ffd31a; 46 | 47 | /** danger **/ 48 | --ion-color-danger: #f04141; 49 | --ion-color-danger-rgb: 245,61,61; 50 | --ion-color-danger-contrast: #ffffff; 51 | --ion-color-danger-contrast-rgb: 255,255,255; 52 | --ion-color-danger-shade: #d33939; 53 | --ion-color-danger-tint: #f25454; 54 | 55 | /** dark **/ 56 | --ion-color-dark: #222428; 57 | --ion-color-dark-rgb: 34,34,34; 58 | --ion-color-dark-contrast: #ffffff; 59 | --ion-color-dark-contrast-rgb: 255,255,255; 60 | --ion-color-dark-shade: #1e2023; 61 | --ion-color-dark-tint: #383a3e; 62 | 63 | /** medium **/ 64 | --ion-color-medium: #989aa2; 65 | --ion-color-medium-rgb: 152,154,162; 66 | --ion-color-medium-contrast: #ffffff; 67 | --ion-color-medium-contrast-rgb: 255,255,255; 68 | --ion-color-medium-shade: #86888f; 69 | --ion-color-medium-tint: #a2a4ab; 70 | 71 | /** light **/ 72 | --ion-color-light: #f4f5f8; 73 | --ion-color-light-rgb: 244,244,244; 74 | --ion-color-light-contrast: #000000; 75 | --ion-color-light-contrast-rgb: 0,0,0; 76 | --ion-color-light-shade: #d7d8da; 77 | --ion-color-light-tint: #f5f6f9; 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "baseUrl": "./", 6 | "module": "es2015" 7 | }, 8 | "exclude": [ 9 | "test.ts", 10 | "**/*.spec.ts" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "types": [ 8 | "jasmine", 9 | "node" 10 | ] 11 | }, 12 | "files": [ 13 | "test.ts" 14 | ], 15 | "include": [ 16 | "polyfills.ts", 17 | "**/*.spec.ts", 18 | "**/*.d.ts" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "outDir": "./dist/out-tsc", 5 | "sourceMap": true, 6 | "declaration": false, 7 | "moduleResolution": "node", 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "target": "es5", 11 | "lib": [ 12 | "es2017", 13 | "dom" 14 | ] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "arrow-return-shorthand": true, 7 | "callable-types": true, 8 | "class-name": true, 9 | "comment-format": [ 10 | true, 11 | "check-space" 12 | ], 13 | "curly": true, 14 | "deprecation": { 15 | "severity": "warn" 16 | }, 17 | "eofline": true, 18 | "forin": true, 19 | "import-spacing": true, 20 | "indent": [ 21 | true, 22 | "spaces" 23 | ], 24 | "interface-over-type-literal": true, 25 | "label-position": true, 26 | "max-line-length": [ 27 | true, 28 | 140 29 | ], 30 | "member-access": false, 31 | "member-ordering": [ 32 | true, 33 | { 34 | "order": [ 35 | "static-field", 36 | "instance-field", 37 | "static-method", 38 | "instance-method" 39 | ] 40 | } 41 | ], 42 | "no-arg": true, 43 | "no-bitwise": true, 44 | "no-console": [ 45 | true, 46 | "debug", 47 | "info", 48 | "time", 49 | "timeEnd", 50 | "trace" 51 | ], 52 | "no-construct": true, 53 | "no-debugger": true, 54 | "no-duplicate-super": true, 55 | "no-empty": false, 56 | "no-empty-interface": true, 57 | "no-eval": true, 58 | "no-inferrable-types": [ 59 | true, 60 | "ignore-params" 61 | ], 62 | "no-misused-new": true, 63 | "no-non-null-assertion": true, 64 | "no-shadowed-variable": true, 65 | "no-string-literal": false, 66 | "no-string-throw": true, 67 | "no-switch-case-fall-through": true, 68 | "no-trailing-whitespace": true, 69 | "no-unnecessary-initializer": true, 70 | "no-unused-expression": true, 71 | "no-use-before-declare": true, 72 | "no-var-keyword": true, 73 | "object-literal-sort-keys": false, 74 | "one-line": [ 75 | true, 76 | "check-open-brace", 77 | "check-catch", 78 | "check-else", 79 | "check-whitespace" 80 | ], 81 | "prefer-const": true, 82 | "quotemark": [ 83 | true, 84 | "single" 85 | ], 86 | "radix": true, 87 | "semicolon": [ 88 | true, 89 | "always" 90 | ], 91 | "triple-equals": [ 92 | true, 93 | "allow-null-check" 94 | ], 95 | "typedef-whitespace": [ 96 | true, 97 | { 98 | "call-signature": "nospace", 99 | "index-signature": "nospace", 100 | "parameter": "nospace", 101 | "property-declaration": "nospace", 102 | "variable-declaration": "nospace" 103 | } 104 | ], 105 | "unified-signatures": true, 106 | "variable-name": false, 107 | "whitespace": [ 108 | true, 109 | "check-branch", 110 | "check-decl", 111 | "check-operator", 112 | "check-separator", 113 | "check-type" 114 | ], 115 | "directive-selector": [ 116 | true, 117 | "attribute", 118 | "app", 119 | "camelCase" 120 | ], 121 | "component-selector": [ 122 | true, 123 | "element", 124 | "app", 125 | "page", 126 | "kebab-case" 127 | ], 128 | "no-output-on-prefix": true, 129 | "use-input-property-decorator": true, 130 | "use-output-property-decorator": true, 131 | "use-host-property-decorator": true, 132 | "no-input-rename": true, 133 | "no-output-rename": true, 134 | "use-life-cycle-interface": true, 135 | "use-pipe-transform-interface": true, 136 | "directive-class-suffix": true 137 | } 138 | } 139 | --------------------------------------------------------------------------------