In this chapter, you got to know Google Firebase. You have read data from a data-base with the aid of HttpClient.
You sorted and filtered data using the Lodash library to make it appealing in the app.
You got to know route parameters as a supplement to the Angular routing con-cept.
Finally, with Local Storage and Ionic Storage, you’ve used a variety of ways to store user-specific data.

Any remarks or questions?

17 comments

  1. Evandro

    Reply

    Hi Andreas!

    In section 5.9, I have executed: npm install –save @ionic/storage and I have imported it in app.module.ts: import { IonicStorageModule } from ‘@ionic/storage’;

    but, I have obtained the following error:

    Module ‘”@ionic/storage”‘ has no exported member ‘IonicStorageModule’.ts(2305)

    My environment is:

    Ionic:

    Ionic CLI : 6.16.3 (C:\Program Files\nodejs\node_modules\@ionic\cli)
    Ionic Framework : @ionic/angular 5.6.11
    @angular-devkit/build-angular : 12.0.5
    @angular-devkit/schematics : 12.1.1
    @angular/cli : 12.0.5
    @ionic/angular-toolkit : 4.0.0

    Cordova:

    Cordova CLI : not installed
    Cordova Platforms : android 9.1.0, ios broken
    Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 5 other plugins)

    Utility:

    cordova-res : 0.15.3
    native-run : 1.4.0

    System:

    NodeJS : v14.17.1 (C:\Program Files\nodejs\node.exe)
    npm : 7.20.5
    OS : Windows 10

    Could you tell me what is wrong?

    • Andionic

      Reply

      Hi Evandro, pls check, if you added IonicStorageModule.forRoot() to the imports array in app.module.ts.

    • Andionic

      Reply

      Evandro, install the @ionic/storage-angular library instead of @ionic/storage:
      npm install @ionic/storage-angular
      In app.module.ts:
      import { IonicStorageModule } from '@ionic/storage-angular';
      In favorites.service.ts:
      import { Storage } from '@ionic/storage-angular';

  2. Papy et les Resistances

    Reply

    Dear Andreas,
    So far, so good…until page 146 (last part of chapter 5 on local memory).
    In your book page 146, you import IonicStorageModule which does not exist: should we replace by Storage instead, like in page 147 for favorites.service.ts ?
    I replaced by Storage but I currently have a blank page when I restart the server. There is something wrong here.
    Could you please help ?
    Cheers,

  3. Charles Almeida

    Reply

    Hi! good evening.
    I have an error:
    core.js: 6162 ERROR TypeError: Cannot read property ‘favTours’ of undefined

    Could you help me, please.

    Grateful.

    • Andionic

      Reply

      You try to assign a property to a non existing object.
      Declare favTours and set a value for it, e.g.
      favTours = {}

  4. Tarcísio

    Reply

    Hi Andreas, thank your for your great book.
    In section 5.9, I executed: npm install –save @ionic/storage
    and I imported in app.module.ts: import { IonicStorageModule } from ‘@ionic/storage’;
    but, I obtained an error:
    ERROR in The target entry-point “@ionic/storage” has missing dependencies:
    [ng] – @angular/core
    [ng] – @angular/common
    [ng]
    [ng] ERROR in ../../../../node_modules/@ionic/storage/index.d.ts:1:37 – error TS2307: Cannot find module ‘@angular/core’ or its corresponding type declarations.
    [ng]
    [ng] 1 import { ModuleWithProviders } from ‘@angular/core’;
    [ng] ~~~~~~~~~~~~~~~
    [ng] ../../../../node_modules/@ionic/storage/storage.d.ts:2:32 – error TS2307: Cannot find module ‘@angular/core’ or its corresponding type declarations.
    [ng]
    [ng] 2 import { InjectionToken } from ‘@angular/core’;
    [ng] ~~~~~~~~~~~~~~~
    [ng]
    .
    How I can solve this?

    • Andionic

      Reply

      Did you add it to the imports section of @NgModule like described on page 147?
      And is your system up to date?

  5. Mark

    Reply

    Andreas,

    This book is wonderful! This is how these books should be written. Thank you!

    I am stuck, however in chapter 5…

    In section 5.5 we add Lodash:
    import _ from ‘lodash’;

    I am getting this problem in the Visual Studio Code error console:
    Module ‘”/home/Projects/ionic/bob-tours/node_modules/@types/lodash/ts3.1/index”‘ can only be default-imported using the ‘allowSyntheticDefaultImports’ flag
    index.d.ts[14,1]: This module is declared with using ‘export =’, and can only be used with a default import when using the ‘allowSyntheticDefaultImports’ flag.

    $ ionic -v
    6.4.3

    Any ideas?

    Thanks!!!

    • Andionic

      Reply

      You’re using TypeScript 3.1. This way you can use

      import * as _ from 'lodash';

      and it should work.

      Thanks for your kind words about my book, Mark! Maybe you would like to write a small review on amazon?

      • Mark

        Reply

        Andreas,

        That did the trick!!! Thanks!

        Thanks for the fast reply. I will mention it in my review 😉

  6. José Augusto de Godoy

    Reply

    Good Morning.
    conexao PHP: $sql = $conexao->prepare(‘SELECT * FROM municipios limit 1’);
    $sql->execute();
    $dados1 = “[“;
    while($lista = $sql->fetch()){$dados1 .=”‘”.$lista[“id”].”‘”‘.’,’;$dados1 .=”‘”.$lista[“uf”].”‘”;}$dados1 .=”]”;
    $dados1json = json_encode($dados1);
    echo ($dados1json);

    Console: “[‘1′,’MS’]”

    bob-tours-service.ts return this.http.get(“http://localhost/conexao.php”).toPromise();
    regions.page.ts: this.btService.getRegions().then(data => this.regions = data);
    So far here all ok
    There is only an error in regions.page.html
    regions.page.html:

    ERROR Error: Cannot find a differ supporting object ‘[“1″,”MS”]’ of type ‘string’. NgFor only supports binding to Iterables such as Arrays.

    Would you help me?

    Thanks.

Leave a comment

Your email address will not be published. Required fields are marked *