cyberfly
6/29/2018 - 1:40 AM

Ionic training notes

How to create new page
==

1. Ionic generate page pokemon-list

2. Pages need to be imported and declared in the declarations and entryComponents inside app.module.ts


Tabs layout
==

1. When using tabs, we need to imported and declared new page inside tabs.ts


Using Ionic provider
==

1. Inject at provider in app.module.ts

2. Import http module in app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule, ErrorHandler } from '@angular/core';
import { HttpModule } from '@angular/http';
...
  imports: [
    BrowserModule,
    HttpModule,
    IonicModule.forRoot(MyApp),
    IonicStorageModule.forRoot()
  ],
...

3. Import HttpClientModule in app.module.ts

==

Navigate to page
==

1. If use lazy loading, no need import page in app.module.ts


Push to ionic view
==

git push ionic master

Troubleshoot common error
==

1. No component factory found for Component

Solution :

Pages need to be imported and declared in the declarations and entryComponents inside app.module.ts

source : https://forum.ionicframework.com/t/rc0-no-component-factory-found-for-componenta/65249/2

2. https://devdactic.com/10-ionic-problems/#more-4104

3. No provider for HTTP error

import { BrowserModule } from '@angular/platform-browser';
import { NgModule, ErrorHandler } from '@angular/core';
import { HttpModule } from '@angular/http';
...
  imports: [
    BrowserModule,
    HttpModule,
    IonicModule.forRoot(MyApp),
    IonicStorageModule.forRoot()
  ],
...

source : https://forum.ionicframework.com/t/no-provider-for-http-error-in-ionic/85762

4. No provider for HTTP client

- Import HttpClientModule in app.module.ts

5. Failed to load. has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

- Use chrome cors extension

5. ionic tabs stuck at about

- comment and ucomment back route

6. undefined object

“Error: Uncaught (in promise): EXCEPTION: TypeError: Cannot read property ‘name’ of undefined in

https://forum.ionicframework.com/t/problem-with-object/51448/2