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

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

  • <tfoot id='KbLsV'></tfoot>
    • <bdo id='KbLsV'></bdo><ul id='KbLsV'></ul>

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

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

      1. 當(dāng) Ionic 2 中的值發(fā)生變化時(shí)檢索本地存儲(chǔ)值

        Retrieve localstorage value when value is change in Ionic 2(當(dāng) Ionic 2 中的值發(fā)生變化時(shí)檢索本地存儲(chǔ)值)
            <bdo id='JPnFy'></bdo><ul id='JPnFy'></ul>

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

              <tbody id='JPnFy'></tbody>

                <legend id='JPnFy'><style id='JPnFy'><dir id='JPnFy'><q id='JPnFy'></q></dir></style></legend>
                • <i id='JPnFy'><tr id='JPnFy'><dt id='JPnFy'><q id='JPnFy'><span id='JPnFy'><b id='JPnFy'><form id='JPnFy'><ins id='JPnFy'></ins><ul id='JPnFy'></ul><sub id='JPnFy'></sub></form><legend id='JPnFy'></legend><bdo id='JPnFy'><pre id='JPnFy'><center id='JPnFy'></center></pre></bdo></b><th id='JPnFy'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='JPnFy'><tfoot id='JPnFy'></tfoot><dl id='JPnFy'><fieldset id='JPnFy'></fieldset></dl></div>
                  <tfoot id='JPnFy'></tfoot>
                  本文介紹了當(dāng) Ionic 2 中的值發(fā)生變化時(shí)檢索本地存儲(chǔ)值的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我正在使用 ionic 2 框架,并嘗試使用本地存儲(chǔ)來(lái)存儲(chǔ)網(wǎng)絡(luò)狀態(tài)

                  I am using ionic 2 framework and I have tried using local storage to store a network status

                  this.local = new Storage(LocalStorage);
                  this.local.set("status", this.status);
                  

                  有兩個(gè)值可以動(dòng)態(tài)分配給狀態(tài),強(qiáng)"和弱".

                  There are 2 values that, "Strong" and "Weak" that can be assigned to status dynamically.

                  我能夠在每個(gè)頁(yè)面初始化時(shí)獲取我的本地存儲(chǔ)狀態(tài)"值的初始值.

                  I am able to get my the initial value of my local storage "status" value on initialization of every page.

                  toCheckStatus();
                  function toCheckStatus()
                  {
                      self.local = new Storage(LocalStorage);
                      self.local.get('status').then((value) => 
                      {
                          console.log("status", value);
                      });
                  }
                  

                  這將返回一個(gè)強(qiáng)"或弱",這正是我想要的,但是否有任何方法或事件可以動(dòng)態(tài)(在狀態(tài)"值更改時(shí))調(diào)用toCheckStatus()"函數(shù)?

                  this will return me a "Strong" or "Weak", which is what I want, but is there any methods or event to dynamically (On "status" value change) call "toCheckStatus()" function?

                  工作流程示例(偽代碼):

                  Workflow Example (pseudo-code):

                  1. 在應(yīng)用程序啟動(dòng)時(shí) -> 檢查互聯(lián)網(wǎng)狀態(tài)(后臺(tái)將不斷檢查并更新本地存儲(chǔ)值)
                  2. 將狀態(tài)存儲(chǔ)到本地存儲(chǔ)
                  3. 調(diào)用函數(shù)獲取值(我的值變化時(shí)如何動(dòng)態(tài)調(diào)用這個(gè)函數(shù),有什么方法嗎?)
                  4. 如果狀態(tài)為弱 -> 顯示弱圖標(biāo)
                  5. 如果狀態(tài)為強(qiáng) -> 顯示強(qiáng)圖標(biāo)

                  推薦答案

                  我的值變化時(shí)如何動(dòng)態(tài)調(diào)用這個(gè)函數(shù),有什么方法嗎?

                  How to dynamically call this function when my value change, is there any method?

                  更好的解決方案是使用 observables.您可以在方法中使用 observables 在屬性更改時(shí)發(fā)出事件,然后執(zhí)行您需要執(zhí)行的代碼.

                  A better solution will be using observables. You can use observables in your methods to emit events when a property is changed and then execute the code you need to execute.

                  這是一個(gè)非常簡(jiǎn)單的使用observables的例子:

                  This is a very simple example of using observables:

                  import {Injectable} from '@angular/core';
                  import {Observable} from 'rxjs/Observable';
                  
                  @Injectable()
                  export class StorageService {
                  
                      private storageObserver: any;
                      public storage: any;
                  
                      constructor(...) {
                          this.storageObserver= null;
                  
                          this.storage= Observable.create(observer => {
                              this.storageObserver= observer;
                          });
                      }
                  
                      public yourMethod(): void { 
                  
                          // This method changes the value of the storage
                          // ...
                  
                          // Notify to the subscriptor that the value has changed
                          this.storageObserver.next(newValue);
                      }
                  

                  然后在你的頁(yè)面中:

                  @Component({
                    templateUrl: 'build/pages/my-new-page/my-new-page.html',
                    providers: [..., StorageService ]
                  })
                  export class MyNewPage {
                  
                      constructor(..., private storageService : StorageService ) {
                  
                          // Initialize all the things you need
                          // ... 
                  
                          this.storageService.storage.subscribe((newValue) => {
                                  // This code will execute when the property has changed and also
                                  // you'll have access to the object with the information that
                                  // your service sent in the next() call.
                                  this.doWhatYouWant(newValue);
                          });
                      }
                  }
                  

                  =============================================

                  ===========================================

                  如果您需要更新視圖中的某些內(nèi)容,因?yàn)楹笈_(tái)發(fā)生了更改,您必須讓 Angular 知道該更改.一種方法是使用 Zones.您可以查看我的答案這里 知道該怎么做.

                  If you need to update something in the view, beacuse of something that has changed in the background, you will have to let Angular know of that change. One way to do it is by using Zones. You can check my answer here to know how to do it.

                  這篇關(guān)于當(dāng) Ionic 2 中的值發(fā)生變化時(shí)檢索本地存儲(chǔ)值的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(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 項(xiàng)目中不起作用)
                  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 用于動(dòng)態(tài)元素 - Angular 2 amp;離子2)
                  <i id='yyFSa'><tr id='yyFSa'><dt id='yyFSa'><q id='yyFSa'><span id='yyFSa'><b id='yyFSa'><form id='yyFSa'><ins id='yyFSa'></ins><ul id='yyFSa'></ul><sub id='yyFSa'></sub></form><legend id='yyFSa'></legend><bdo id='yyFSa'><pre id='yyFSa'><center id='yyFSa'></center></pre></bdo></b><th id='yyFSa'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='yyFSa'><tfoot id='yyFSa'></tfoot><dl id='yyFSa'><fieldset id='yyFSa'></fieldset></dl></div>
                      <tbody id='yyFSa'></tbody>
                      <bdo id='yyFSa'></bdo><ul id='yyFSa'></ul>

                    • <tfoot id='yyFSa'></tfoot>
                        1. <small id='yyFSa'></small><noframes id='yyFSa'>

                          <legend id='yyFSa'><style id='yyFSa'><dir id='yyFSa'><q id='yyFSa'></q></dir></style></legend>

                          • 主站蜘蛛池模板: 色视频www在线播放国产人成 | 精品小视频 | 欧美久久久久久 | 黑人操亚洲女人 | 欧美一区二区三区视频 | 久久99热这里只频精品6学生 | 大色av | 日韩免费成人 | 日本少妇久久 | 成人免费网站黄 | 激情综合五月天 | 成人免费看片在线观看 | 久久综合五月天 | 99re视频| 久久久精品国产sm调教 | 欧美极品一区 | 久久免费网 | 色婷婷国产| 日韩国产在线观看 | 国产一区在线看 | 亚洲高清视频在线观看 | 国产精品一区二区免费 | 好好的日com | 国产日韩在线播放 | 黄色av一区 | 黄色片免费看 | 久久久久一区二区三区 | 黄色av毛片| 亚洲福利片 | 四虎永久网址 | 日本天堂在线 | 日韩在线一区二区三区 | 一区二区三区精品 | 在线一区二区三区 | 国产精品成人免费一区久久羞羞 | 久久精品视频网 | 欧美一级做性受免费大片免费 | 成人av网站在线观看 | 国产在线第一页 | 久久视频一区二区 | 亚洲九九九 |