久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <i id='tMvsk'><tr id='tMvsk'><dt id='tMvsk'><q id='tMvsk'><span id='tMvsk'><b id='tMvsk'><form id='tMvsk'><ins id='tMvsk'></ins><ul id='tMvsk'></ul><sub id='tMvsk'></sub></form><legend id='tMvsk'></legend><bdo id='tMvsk'><pre id='tMvsk'><center id='tMvsk'></center></pre></bdo></b><th id='tMvsk'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='tMvsk'><tfoot id='tMvsk'></tfoot><dl id='tMvsk'><fieldset id='tMvsk'></fieldset></dl></div>
        <bdo id='tMvsk'></bdo><ul id='tMvsk'></ul>

      1. <tfoot id='tMvsk'></tfoot>
        <legend id='tMvsk'><style id='tMvsk'><dir id='tMvsk'><q id='tMvsk'></q></dir></style></legend>

        <small id='tMvsk'></small><noframes id='tMvsk'>

        Ionic2 錯誤:“沒有存儲提供程序"

        Ionic2 Error: quot;No provider for Storagequot;(Ionic2 錯誤:“沒有存儲提供程序)

          <small id='INxm0'></small><noframes id='INxm0'>

          • <tfoot id='INxm0'></tfoot>

            • <bdo id='INxm0'></bdo><ul id='INxm0'></ul>

            • <legend id='INxm0'><style id='INxm0'><dir id='INxm0'><q id='INxm0'></q></dir></style></legend>

                  <tbody id='INxm0'></tbody>
                <i id='INxm0'><tr id='INxm0'><dt id='INxm0'><q id='INxm0'><span id='INxm0'><b id='INxm0'><form id='INxm0'><ins id='INxm0'></ins><ul id='INxm0'></ul><sub id='INxm0'></sub></form><legend id='INxm0'></legend><bdo id='INxm0'><pre id='INxm0'><center id='INxm0'></center></pre></bdo></b><th id='INxm0'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='INxm0'><tfoot id='INxm0'></tfoot><dl id='INxm0'><fieldset id='INxm0'></fieldset></dl></div>
                  本文介紹了Ionic2 錯誤:“沒有存儲提供程序"的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  在閱讀了我能找到的所有內(nèi)容并且失敗后,我必須在這里問:

                  After reading everything I could find, and failing, I must ask here:

                  我正在嘗試使用 ionic2 的存儲,就像文檔告訴我的那樣,

                  I am trying to use ionic2's Storage, just like the doc tells me to,

                  文檔:https://ionicframework.com/docs/storage/

                  這是我的代碼:

                  應用模塊.ts

                      import { BrowserModule } from '@angular/platform-browser';
                      import { ErrorHandler, NgModule } from '@angular/core';
                      import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
                      import { SplashScreen } from '@ionic-native/splash-screen';
                      import { StatusBar } from '@ionic-native/status-bar';
                  
                      import { MyApp } from './app.component';
                      import { HomePage } from '../pages/home/home';
                      import { Intro } from '../pages/intro/intro';
                      import { Checklist } from '../pages/checklist/checklist';
                      // import { Http } from '@angular/http';
                      import {IonicStorageModule} from '@ionic/Storage';
                      import { Data } from '../providers/data';
                      import {HttpModule} from '@angular/http';
                      // import {Storage} from '@ionic/storage';
                  
                  
                      @NgModule({
                        declarations: [
                          MyApp,
                          HomePage,
                          Intro,
                          Checklist
                        ],
                        imports: [
                          HttpModule,
                          BrowserModule,
                          IonicModule.forRoot(MyApp),
                          IonicStorageModule.forRoot()
                        ],
                        bootstrap: [IonicApp],
                        entryComponents: [
                          MyApp,
                          HomePage,
                          Intro,
                          Checklist
                        ],
                        providers: [
                          StatusBar,
                          SplashScreen,
                          {provide: ErrorHandler, useClass: IonicErrorHandler},
                          // Storage,
                          //Http,
                          Data
                        ],
                      })
                      export class AppModule {}
                  
                  
                  data.ts
                  
                  import { Injectable } from '@angular/core';
                  // import { Http } from '@angular/http';
                  import 'rxjs/add/operator/map';
                  // import { HttpModule } from '@angular/http';
                  
                  import { Storage } from '@ionic/storage';
                  
                  
                  @Injectable()
                  export class Data {
                    constructor(public storage: Storage) {
                    }
                  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    getData(): Promise<any> {
                      return this.storage.get('checklists');
                    }
                  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    save(data): void {
                      let saveData = [];
                      //Remove observables
                      data.forEach((checklist) => {
                        saveData.push({
                          title: checklist.title,
                          items: checklist.items
                        });
                      });
                      let newData = JSON.stringify(saveData);
                      this.storage.set('checklists', newData);
                    }
                  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                  }
                  

                  home.ts

                  // import { Component } from '@angular/core';
                  // import { NavController } from 'ionic-angular';
                  
                  // @Component({
                  //   selector: 'page-home',
                  //   templateUrl: 'home.html'
                  // })
                  // export class HomePage {
                  
                  //   constructor(public navCtrl: NavController) {
                  
                  //   }
                  
                  // }
                  
                  
                  import { Component } from '@angular/core';
                  import { NavController, AlertController, Platform } from 'ionic-angular';
                  import { Checklist } from '../checklist/checklist';
                  import { ChecklistModel } from '../../models/checklist-model';
                  import { Data } from '../../providers/data';
                  import { Keyboard } from 'ionic-native';
                  @Component({
                    selector: 'page-home',
                    templateUrl: 'home.html',
                  })
                  export class HomePage {
                    checklists: ChecklistModel[] = [];
                  
                    constructor(public navCtrl: NavController, public dataService: Data,
                      public alertCtrl: AlertController, public platform: Platform) {
                    }
                  
                    // constructor(public navCtrl: NavController, public alertCtrl: AlertController, public platform: Platform) {
                    //   // this.checklists.push(new ChecklistModel("Noam", [1,2,3]));
                    // }
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////////
                    ionViewDidLoad() {
                    }
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////////
                    addChecklist(): void {
                      let prompt = this.alertCtrl.create({
                        title: 'New Checklist',
                        message: 'Enter the name of your new checklist below:',
                        inputs: [
                          {
                            name: 'name'
                          }
                        ],
                        buttons: [
                          {
                            text: 'Cancel'
                          },
                          {
                            text: 'Save',
                            handler: data => {
                              let newChecklist = new ChecklistModel(data.name, []);
                              this.checklists.push(newChecklist);
                              newChecklist.checklistUpdates().subscribe(update => {
                                this.save();
                              });
                              this.save();
                            }
                          }
                        ]
                      });
                      prompt.present();
                    }
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////////
                    renameChecklist(checklist): void {
                      let prompt = this.alertCtrl.create({
                        title: 'Rename Checklist',
                  
                        message: 'Enter the new name of this checklist below:',
                        inputs: [
                          {
                            name: 'name'
                          }
                        ],
                        buttons: [
                          {
                            text: 'Cancel'
                          },
                          {
                            text: 'Save',
                            handler: data => {
                              let index = this.checklists.indexOf(checklist);
                              if (index > -1) {
                                this.checklists[index].setTitle(data.name);
                                this.save();
                              }
                            }
                          }
                        ]
                      });
                      prompt.present();
                    }
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////////
                    viewChecklist(checklist): void {
                      this.navCtrl.push(Checklist, {
                        checklist: checklist
                      });
                    }
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////////
                    removeChecklist(checklist): void {
                      let index = this.checklists.indexOf(checklist);
                      if (index > -1) {
                        this.checklists.splice(index, 1);
                        this.save();
                      }
                    }
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////////
                    save(): void {
                      Keyboard.close();
                      this.dataService.save(this.checklists);
                    }
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////////
                  }
                  

                  應該被調(diào)用和使用存儲的方法是主頁的save().

                  The method that is supposed to get called and use the Storage is HomePage's save().

                  但是,我無法做到這一點,因為在頁面加載之前,我就得到了

                  I can't get that far, however, because before the page even loads, I get

                  未捕獲運行時錯誤(承諾):錯誤:沒有存儲提供程序!g (http://localhost:8100/build/polyfills.js:3:7133 錯誤) 在injectionError (http://localhost:8100/build/main.js:1585:86) 在noProviderError (http://localhost:8100/build/main.js:1623:12) 在ReflectiveInjector_.throwOrNull(http://localhost:8100/build/main.js:3125:19) 在ReflectiveInjector.getByKeyDefault(http://localhost:8100/build/main.js:3164:25) 在ReflectiveInjector.getByKey(http://localhost:8100/build/main.js:3096:25) 在ReflectiveInjector.get (http://localhost:8100/build/main.js:2965:21)在 AppModuleInjector.get (ng:///AppModule/module.ngfactory.js:254:82)在 AppModuleInjector.getInternal(ng:///AppModule/module.ngfactory.js:481:44) 在AppModuleInjector.NgModuleInjector.get(http://localhost:8100/build/main.js:3929:44) 在 resolveDep(http://localhost:8100/build/main.js:11334:45) 在創(chuàng)建類(http://localhost:8100/build/main.js:11202:32) 在createDirectiveInstance (http://localhost:8100/build/main.js:11028:37)在 createViewNodes (http://localhost:8100/build/main.js:12377:49) 在createRootView (http://localhost:8100/build/main.js:12282:5)

                  Runtime Error Uncaught (in promise): Error: No provider for Storage! Error at g (http://localhost:8100/build/polyfills.js:3:7133) at injectionError (http://localhost:8100/build/main.js:1585:86) at noProviderError (http://localhost:8100/build/main.js:1623:12) at ReflectiveInjector_.throwOrNull (http://localhost:8100/build/main.js:3125:19) at ReflectiveInjector.getByKeyDefault (http://localhost:8100/build/main.js:3164:25) at ReflectiveInjector.getByKey (http://localhost:8100/build/main.js:3096:25) at ReflectiveInjector.get (http://localhost:8100/build/main.js:2965:21) at AppModuleInjector.get (ng:///AppModule/module.ngfactory.js:254:82) at AppModuleInjector.getInternal (ng:///AppModule/module.ngfactory.js:481:44) at AppModuleInjector.NgModuleInjector.get (http://localhost:8100/build/main.js:3929:44) at resolveDep (http://localhost:8100/build/main.js:11334:45) at createClass (http://localhost:8100/build/main.js:11202:32) at createDirectiveInstance (http://localhost:8100/build/main.js:11028:37) at createViewNodes (http://localhost:8100/build/main.js:12377:49) at createRootView (http://localhost:8100/build/main.js:12282:5)

                  包.json:

                  {
                    "name": "ionic-hello-world",
                    "author": "Ionic Framework",
                    "homepage": "http://ionicframework.com/",
                    "private": true,
                    "config": {
                      "ionic_source_map": "source-map"
                    },
                    "scripts": {
                      "clean": "ionic-app-scripts clean",
                      "build": "ionic-app-scripts build",
                      "ionic:build": "ionic-app-scripts build",
                      "ionic:serve": "ionic-app-scripts serve"
                    },
                    "dependencies": {
                      "@angular/common": "4.0.0",
                      "@angular/compiler": "4.0.0",
                      "@angular/compiler-cli": "4.0.0",
                      "@angular/core": "4.0.0",
                      "@angular/forms": "4.0.0",
                      "@angular/http": "4.0.0",
                      "@angular/platform-browser": "4.0.0",
                      "@angular/platform-browser-dynamic": "4.0.0",
                      "@ionic-native/core": "3.4.2",
                      "@ionic-native/splash-screen": "3.4.2",
                      "@ionic-native/status-bar": "3.4.2",
                      "@ionic/storage": "^2.0.1",
                      "ionic-angular": "3.0.1",
                      "ionic-native": "^2.9.0",
                      "ionicons": "3.0.0",
                      "rxjs": "5.1.1",
                      "sw-toolbox": "3.4.0",
                      "zone.js": "^0.8.4"
                    },
                    "devDependencies": {
                      "@ionic/app-scripts": "1.3.0",
                      "typescript": "~2.2.1",
                      "webpack": "^2.4.1"
                    },
                    "cordovaPlugins": [
                      "cordova-plugin-whitelist",
                      "cordova-plugin-console",
                      "cordova-plugin-statusbar",
                      "cordova-plugin-device",
                      "cordova-plugin-splashscreen",
                      "ionic-plugin-keyboard"
                    ],
                    "cordovaPlatforms": [],
                    "description": "quicklists: An Ionic project"
                  }
                  

                  既然我做了文檔所說的一切,請賜教 - 仍然缺少什么會導致找不到存儲

                  Since I did everything the doc said, please enlighten me - What is still missing that would cause the Storage not to be found

                  謝謝

                  推薦答案

                  首先需要安裝:npm install --save @ionic/storage

                  問題出在 app.ts 中:

                  The problem was in app.ts:

                  import {IonicStorageModule} from '@ionic/Storage';
                  

                  大寫S"而不是非大寫s":

                  Capital 'S' instead of non capital 's':

                  from '@ionic/Storage'
                  

                  代替:

                  from '@ionic/storage'
                  

                  不知道為什么編譯器不會發(fā)現(xiàn)問題,但它沒有.

                  No idea why the compiler wouldn't catch that if it's a problem, but it didn't.

                  感謝@chairmanmow

                  Thanks to @chairmanmow

                  編輯

                  這個答案曾經(jīng)得到很多支持,但后來停止了.

                  This answer used to get a lot of upvotes, and that stopped.

                  我只能假設這是由于版本更新/錯誤修復.

                  I can only assume this is due to version updates/bug fixes.

                  我建議您在繼續(xù)使用此解決方案之前更新您的角度.

                  I suggest you update your angular before going forward with this solution.

                  這篇關(guān)于Ionic2 錯誤:“沒有存儲提供程序"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數(shù)據(jù)更新 Observable)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創(chuàng)建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態(tài)元素 - Angular 2 amp;離子2)
                  <i id='9cxVF'><tr id='9cxVF'><dt id='9cxVF'><q id='9cxVF'><span id='9cxVF'><b id='9cxVF'><form id='9cxVF'><ins id='9cxVF'></ins><ul id='9cxVF'></ul><sub id='9cxVF'></sub></form><legend id='9cxVF'></legend><bdo id='9cxVF'><pre id='9cxVF'><center id='9cxVF'></center></pre></bdo></b><th id='9cxVF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='9cxVF'><tfoot id='9cxVF'></tfoot><dl id='9cxVF'><fieldset id='9cxVF'></fieldset></dl></div>
                    • <small id='9cxVF'></small><noframes id='9cxVF'>

                      <legend id='9cxVF'><style id='9cxVF'><dir id='9cxVF'><q id='9cxVF'></q></dir></style></legend>

                            <tbody id='9cxVF'></tbody>
                            <bdo id='9cxVF'></bdo><ul id='9cxVF'></ul>

                            <tfoot id='9cxVF'></tfoot>

                          • 主站蜘蛛池模板: 国产中文字幕在线观看 | 污视频免费在线观看 | 婷婷久久综合 | 久久久久黄色 | 中文字幕在线电影观看 | 亚洲一区在线日韩在线深爱 | 中文字幕av网站 | 国产成人免费视频网站高清观看视频 | 日日摸日日碰夜夜爽2015电影 | 国产精品精品视频一区二区三区 | 91麻豆久久久 | 欧美精品一区二区三区在线四季 | 91精品国产日韩91久久久久久 | 国产精品观看 | 久草青青 | 久久精品亚洲欧美日韩精品中文字幕 | 美女黄18岁以下禁止观看 | 日韩视频在线一区 | 久久国产精品久久久久久久久久 | 国产成人综合在线 | 91网站在线看 | 亚洲视频一区 | 日日摸天天添天天添破 | 白浆在线 | 日日干日日操 | 日韩欧美在线视频 | 九九九视频在线观看 | 国产精品久久毛片av大全日韩 | 国产精品激情小视频 | 国产综合久久 | 国产成人精品一区二区三区 | 特级毛片爽www免费版 | 精品日韩一区二区 | 亚洲成人一二三 | 羞羞免费网站 | 欧美午夜一区 | 亚洲成人免费视频 | 国产美女精品 | 日韩视频a | 成人一区二区在线 | 一区二区三区四区不卡视频 |