久久久久久久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. 當 Ionic 2 中的值發生變化時檢索本地存儲值

        Retrieve localstorage value when value is change in Ionic 2(當 Ionic 2 中的值發生變化時檢索本地存儲值)
            <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>
                  本文介紹了當 Ionic 2 中的值發生變化時檢索本地存儲值的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在使用 ionic 2 框架,并嘗試使用本地存儲來存儲網絡狀態

                  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);
                  

                  有兩個值可以動態分配給狀態,強"和弱".

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

                  我能夠在每個頁面初始化時獲取我的本地存儲狀態"值的初始值.

                  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);
                      });
                  }
                  

                  這將返回一個強"或弱",這正是我想要的,但是否有任何方法或事件可以動態(在狀態"值更改時)調用toCheckStatus()"函數?

                  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. 在應用程序啟動時 -> 檢查互聯網狀態(后臺將不斷檢查并更新本地存儲值)
                  2. 將狀態存儲到本地存儲
                  3. 調用函數獲取值(我的值變化時如何動態調用這個函數,有什么方法嗎?)
                  4. 如果狀態為弱 -> 顯示弱圖標
                  5. 如果狀態為強 -> 顯示強圖標

                  推薦答案

                  我的值變化時如何動態調用這個函數,有什么方法嗎?

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

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

                  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.

                  這是一個非常簡單的使用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);
                      }
                  

                  然后在你的頁面中:

                  @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);
                          });
                      }
                  }
                  

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

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

                  如果您需要更新視圖中的某些內容,因為后臺發生了更改,您必須讓 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.

                  這篇關于當 Ionic 2 中的值發生變化時檢索本地存儲值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  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 - 使用異步數據更新 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 中,如何創建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態元素 - 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>

                          • 主站蜘蛛池模板: 欧美1页 | 羞视频在线观看 | 罗宾被扒开腿做同人网站 | 国产传媒在线观看 | 好姑娘高清在线观看电影 | 人人干人人干人人干 | 国产精品自产拍 | 欧美一级片a | 羞羞的视频免费在线观看 | 伊人久久精品一区二区三区 | 国产成人99久久亚洲综合精品 | 国产资源在线视频 | .国产精品成人自产拍在线观看6 | 一二三在线视频 | 免费一二区 | 伊人色综合久久久天天蜜桃 | 国产一区二区三区高清 | 日韩免费高清视频 | 日韩和的一区二在线 | 中文字幕亚洲无线 | 特黄色一级毛片 | 婷婷99| 久草新在线 | 久久久片 | 国产精品久久久久久婷婷天堂 | 免费国产一区二区视频 | 中文字幕亚洲区 | 欧美成人精品在线 | 欧美一级二级视频 | 国产精品免费一区二区三区 | 黄色av一区 | 色免费视频 | 欧美日韩国产在线观看 | 老司机狠狠爱 | 中文字幕成人av | 日本在线小视频 | 国产高清无av久久 | 97超碰人人草 | a级免费黄色片 | 精品日韩一区二区 | 99精品久久99久久久久 |