subscribe

Angular 2+ wait for subscribe to finish to update/access variable

余生长醉 提交于 2020-05-26 10:39:07
问题 Hello I am having an issue with my variables being undefined. I am certain this is because the observable hasnt finished. Here is the part of my code in my .ts file that is causing the issue: (I'm placing the minimum code required to understand the issue, if I need to provide more code and context let me know. Also myFunction gets called from a click event in the html.) export class myClass { myVariable: any; myFunction() { this.myService.getApi().subscribe(data => { this.myVariable = data; }

Undefined varibale already declared whet getting data from api on ngOnInit

风格不统一 提交于 2020-05-17 06:36:31
问题 I'm trying to fetch data from nodeJS API with angular, I have a variable declared and I want to affect the response from server to it, here is my code : export class SondageSingleComponent implements OnInit, AfterViewInit { @ViewChild('containerPieChart') element: ElementRef; survey: any = {}; currentUser: any; statistics: any; colorCounter: any = 0; d3Colors: any[] = ["#3182bd", "#6baed6", "#9ecae1", "#c6dbef", "#e6550d"]; private host: D3.Selection; private svg: D3.Selection; private width:

Undefined varibale already declared whet getting data from api on ngOnInit

删除回忆录丶 提交于 2020-05-17 06:36:14
问题 I'm trying to fetch data from nodeJS API with angular, I have a variable declared and I want to affect the response from server to it, here is my code : export class SondageSingleComponent implements OnInit, AfterViewInit { @ViewChild('containerPieChart') element: ElementRef; survey: any = {}; currentUser: any; statistics: any; colorCounter: any = 0; d3Colors: any[] = ["#3182bd", "#6baed6", "#9ecae1", "#c6dbef", "#e6550d"]; private host: D3.Selection; private svg: D3.Selection; private width:

Angular 9 http call with nestjs backend

蓝咒 提交于 2020-04-18 04:04:08
问题 I have an Angular (9) frontend with nestjs backend rest api (in nodejs) The endpoint I call in the backend does some fairly complex operations and it takes about 2 min to respond. In the frontend I use subscribe to subscribe to the response like this: this.metaService.subscribe( result => { //Handle result }, error => { this.subscription.unsubscribe(); console.error('Error: ' + error); }, () => { this.subscription.unsubscribe(); console.error('Completed'); }); The problem is that in the

Angular 9 http call with nestjs backend

♀尐吖头ヾ 提交于 2020-04-18 04:00:30
问题 I have an Angular (9) frontend with nestjs backend rest api (in nodejs) The endpoint I call in the backend does some fairly complex operations and it takes about 2 min to respond. In the frontend I use subscribe to subscribe to the response like this: this.metaService.subscribe( result => { //Handle result }, error => { this.subscription.unsubscribe(); console.error('Error: ' + error); }, () => { this.subscription.unsubscribe(); console.error('Completed'); }); The problem is that in the

How to subscribe asynchronously to matdialog service for candeactivate guard?

二次信任 提交于 2020-04-17 22:16:07
问题 I have implemented candeactivate guard using angular forms validation. If user clicks on an ngForm Field. and tries to navigate to different Tab, user will get a custom confirmation Popup, which will say "Discard Changes ? " and returns true or false. This is my form guard import { NgForm } from "@angular/forms"; import { ComponentCanDeactivate } from './component-can-deactivate'; export abstract class FormCanDeactivate extends ComponentCanDeactivate { abstract get form(): NgForm;

mqtt error void callback/subscribed on arduino

陌路散爱 提交于 2020-03-26 04:38:29
问题 I'm testing with my arduino and MQTT cloud. For the publish everything goes well, the arduino publishes "hello world" But with the void callback function nothing happens. With my MQTT.fx client, I'm subscribed to the topics "status" and "commando". At the "status" I see that the arduino is a live. When I publish with my MQTT.fx client to the topic "commando". I can see it arrived in my client, but not in the serial monitor of the arduino. Why is the void callback function not used? #include

BehaviorSubject can not receive value with subscribe

时光总嘲笑我的痴心妄想 提交于 2020-01-15 09:08:01
问题 In My Angular Application I made several attempts to get the values using a BehaviorSubject to know when the value was changed or received. I can not get the values before loading the component. Through this link you can see what you are returning: https://dev.moip.com.br/v1.5/reference#listar-planos data.service.ts: dataOnChanged: BehaviorSubject<any> = new BehaviorSubject({}); getData() { return new Promise((resolve, reject) => { this.http.get(this.api_URL + 'plans/, this.httpOptions)

BehaviorSubject can not receive value with subscribe

为君一笑 提交于 2020-01-15 09:04:16
问题 In My Angular Application I made several attempts to get the values using a BehaviorSubject to know when the value was changed or received. I can not get the values before loading the component. Through this link you can see what you are returning: https://dev.moip.com.br/v1.5/reference#listar-planos data.service.ts: dataOnChanged: BehaviorSubject<any> = new BehaviorSubject({}); getData() { return new Promise((resolve, reject) => { this.http.get(this.api_URL + 'plans/, this.httpOptions)

Voicemail detection on FreeSWITCH

拟墨画扇 提交于 2020-01-05 07:04:12
问题 I am working on a predictive dialer-like application in which I should detect whether the call was picked up by a voicemail or not. I am using the follwing: Server: I am using FreeSWITCH v1.6.11. I built and configured AVMD module. Client: I am using sipml5 connected to Freeswitch via WSS. The idea is when Freeswitch detects a beep sound, it will fire an event called AVMD_EVENT_BEEP. In the following log, I am using a telnet client connected to FreeSWITCH socket. I subscribed to the event via