我很难理解如何在不触发UI事件的情况下将组件内的属性更改传播到实际视图.如果我来回走动,UI会更新.
这是我的组件,它每秒检索一次BLE通知.每次通知后,需要在视图中更新通知的结果值.我可以在开发者控制台中看到显示的通知.
import { Component, ChangeDetectionStrategy, ChangeDetectorRef, Input, Output} from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { BLE } from 'ionic-native';
import {Observable} from 'rxjs/Observable';
@Component({
templateUrl: 'build/pages/devices/devices.html',
//changeDetection: ChangeDetectionStrategy.OnPush
})
export class DevicePage {
private nav:NavController = null;
private navParams:NavParams = null;
private device:any;
private connecting:any;
private characteristics:any;
private data:any;
private temp:any;
static get parameters() {
return [[NavParams],[NavController]];
}
//
constructor(navParams, nav, private cd:ChangeDetectorRef ) {
this.nav = nav;
this.navParams = navParams;
this.device = this.navParams.get('device');
this.connect(this.device.id); …Run Code Online (Sandbox Code Playgroud)