本文整理汇总了TypeScript中@angular/core.ChangeDetectorRef.detectChanges方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ChangeDetectorRef.detectChanges方法的具体用法?TypeScript ChangeDetectorRef.detectChanges怎么用?TypeScript ChangeDetectorRef.detectChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/core.ChangeDetectorRef
的用法示例。
在下文中一共展示了ChangeDetectorRef.detectChanges方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
this.instances$.then(instances => {
this.changeDetector.detectChanges();
this.selectionList.options.forEach(option => {
if (option.value === instance.name) {
option.selected = true;
}
});
this.changeDetector.detectChanges();
});
示例2:
this.geocoder.geocode({'address': address}, (results, status) => {
if (status === google.maps.GeocoderStatus.OK) {
this.contact.coordinates = results[0].geometry.location.lat().toString() + ',' + results[0].geometry.location.lng().toString();
this.errorAddress = false;
this.changeDetectorRef.detectChanges();
} else {
this.errorAddress = true;
this.changeDetectorRef.detectChanges();
}
});
示例3: switch
this.init.getFilterContentData(f).subscribe(res =>{
switch (res.status) {
case false:
this.dataNotFound = !res.status;
this.chng.detectChanges()
break;
case true:
this.dataNotFound = !res.status;
this.chng.detectChanges()
break;
}
this.responsesFound = res.content.length;
this.chng.detectChanges()
this.contentData.next(res.content.content)
})
示例4: onMessageReceived
private onMessageReceived(e: MessageEvent) {
console.log('remote got a messsage ', e.data, e.origin);
if (e.origin === 'http://localhost:3000') {
this.message = e.data;
this.changeDetectorRef.detectChanges();
}
}
示例5:
this.client.emitter.subscribe((message) => {
if (message === 'open') {
this.isConnected = true;
this.headerState = 'inactive';
this.isConnecting = false;
let msg = JSON.stringify({
tracks: this.tracks,
currentTrack: this.currentTrack,
control: 'tracklist'
});
if (this.client && this.client.channel) {
this.client.channel.send(msg);
}
this.client.observer.subscribe((res) => {
let msg = res[res.length - 1].data;
this.updateMessages(msg);
});
this.ref.detectChanges();
}
});
示例6:
response.text().then(text => {
this.scriptContainer.nativeElement.innerHTML = text;
this.editor = ace.edit(this.scriptContainer.nativeElement);
this.editor.setReadOnly(true);
this.editor.getSession().setMode('ace/mode/javascript');
this.changeDetector.detectChanges();
});
示例7:
]).then(selections => {
this.selectedExchange = selections[0];
this.selectedCurrency = selections[1];
this.availableCurrencies = selections[2];
this.changeDetector.detectChanges();
this.stopLoading();
});
示例8:
this.sessionTimedOutSubject.subscribe(e => {
this.showSessionTimeout = !FT.isApplicationEmbedded();
// Since anyone can call sessionTimedOutSubject,
// an update can happen outside of the Angular Zone and would not
// detect a change, therefore call it manually
this.cd.detectChanges();
});
示例9: ngAfterViewInit
ngAfterViewInit() {
this.basicGrid.setSort('name');
this.basicGrid.setPageSize(50);
this.basicGrid.render();
this.changeDetectorRef.detectChanges();
}
示例10: if
device => {
if (device.rssi <= -95) {
this.vibrationThreshold += 1;
device.distance = "far";
} else if (device.rssi > -95 && device.rssi <= -80) {
this.vibrationThreshold += 1;
device.distance = "not so close";
} else if (device.rssi > -80) {
this.vibrationThreshold = 0;
device.distance = "close";
}
if (this.vibrationThreshold >= 3) {
console.log("Attempting to vibrate...");
Vibration.vibrate(2000);
}
this.foundDevices.push(device);
console.log("Found: " + JSON.stringify(device));
// It seems I need to use the ChangeDetectorRef to get the UI to update whenever a device is detected
this.cd.detectChanges();
},