pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <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="p7smly7" 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="x3znxkp" 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="k1dm2cv" 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>

                          • 主站蜘蛛池模板: 宝元数控系统|对刀仪厂家|东莞机器人控制系统|东莞安川伺服-【鑫天驰智能科技】 | 油缸定制-液压油缸厂家-无锡大鸿液压气动成套有限公司 | 药品/药物稳定性试验考察箱-埃里森仪器设备(上海)有限公司 | 飞飞影视_热门电影在线观看_影视大全 | 智能家居全屋智能系统多少钱一套-小米全套价格、装修方案 | 短信营销平台_短信群发平台_106短信发送平台-河南路尚 | 万博士范文网-您身边的范文参考网站Vanbs.com | 二手电脑回收_二手打印机回收_二手复印机回_硒鼓墨盒回收-广州益美二手电脑回收公司 | 模温机-油温机-电加热导热油炉-工业冷水机「欧诺智能」 | 成都治疗尖锐湿疣比较好的医院-成都治疗尖锐湿疣那家医院好-成都西南皮肤病医院 | 多物理场仿真软件_电磁仿真软件_EDA多物理场仿真软件 - 裕兴木兰 | 铝板冲孔网,不锈钢冲孔网,圆孔冲孔网板,鳄鱼嘴-鱼眼防滑板,盾构走道板-江拓数控冲孔网厂-河北江拓丝网有限公司 | 新疆系统集成_新疆系统集成公司_系统集成项目-新疆利成科技 | uv机-uv灯-uvled光固化机-生产厂家-蓝盾机电 | 兰州UPS电源,兰州山特UPS-兰州万胜商贸 | 石家庄救护车出租_重症转院_跨省跨境医疗转送_活动赛事医疗保障_康复出院_放弃治疗_腾康26年医疗护送转诊团队 | 哈希余氯测定仪,分光光度计,ph在线监测仪,浊度测定仪,试剂-上海京灿精密机械有限公司 | 厦门ISO认证|厦门ISO9001认证|厦门ISO14001认证|厦门ISO45001认证-艾索咨询专注ISO认证行业 | 北京开源多邦科技发展有限公司官网| 红立方品牌应急包/急救包加盟,小成本好项目代理_应急/消防/户外用品加盟_应急好项目加盟_新奇特项目招商 - 中红方宁(北京) 供应链有限公司 | 金刚网,金刚网窗纱,不锈钢网,金刚网厂家- 河北萨邦丝网制品有限公司 | 昊宇水工|河北昊宇水工机械工程有限公司 | 钢板仓,大型钢板仓,钢板库,大型钢板库,粉煤灰钢板仓,螺旋钢板仓,螺旋卷板仓,骨料钢板仓 | 展厅设计公司,展厅公司,展厅设计,展厅施工,展厅装修,企业展厅,展馆设计公司-深圳广州展厅设计公司 | 间甲酚,间甲酚厂家-山东祥东新材料 | 交联度测试仪-湿漏电流测试仪-双85恒温恒湿试验箱-常州市科迈实验仪器有限公司 | 蜗轮丝杆升降机-螺旋升降机-丝杠升降机厂家-润驰传动 | 网站建设-高端品牌网站设计制作一站式定制_杭州APP/微信小程序开发运营-鼎易科技 | 氟塑料磁力泵-不锈钢离心泵-耐腐蚀化工泵厂家「皖金泵阀」 | 无缝钢管-聊城无缝钢管-小口径无缝钢管-大口径无缝钢管 - 聊城宽达钢管有限公司 | 压砖机_电动螺旋压力机_粉末成型压力机_郑州华隆机械tel_0371-60121717 | 爆炸冲击传感器-无线遥测传感器-航天星百科 | 选宝石船-陆地水上开采「精选」色选机械设备-青州冠诚重工机械有限公司 | 金属切削液-脱水防锈油-电火花机油-抗磨液压油-深圳市雨辰宏业科技发展有限公司 | 翻斗式矿车|固定式矿车|曲轨侧卸式矿车|梭式矿车|矿车配件-山东卓力矿车生产厂家 | 软文世界-软文推广-软文营销-新闻稿发布-一站式软文自助发稿平台 | 北京律师事务所_房屋拆迁律师_24小时免费法律咨询_云合专业律师网 | 硬齿面减速机[型号全],ZQ减速机-淄博久增机械 | 拉卡拉POS机官网 - 官方直营POS机办理|在线免费领取 | 生鲜配送系统-蔬菜食材配送管理系统-连锁餐饮订货配送软件-挪挪生鲜供应链管理软件 | 骨密度检测仪_骨密度分析仪_骨密度仪_动脉硬化检测仪专业生产厂家【品源医疗】 |