I have service which returns an observable which does an http request to my server and gets the data. I want to use this data but I always end up getting undefined. What's the problem?  Service:  @Injectable() export class EventService {    con...
In Angular 1.x I would sometimes need to make multiple http requests and do something with all the responses. I would throw all the promises in an array and call Promise.all(promises).then(function (results) {...}).  Angular 2 best practices seem t...
Say I have an Observable, like so:  var one = someObservable.take(1);  one.subscribe(function(){ /* do something */ });   Then, I have a second Observable:  var two = someOtherObservable.take(1);   Now, I want to subscribe() to two, but I want to m...
So I am trying to subscribe to a simple service that return data from a local JSON file.   I have managed to get the service working, I can log it out in the function, but when I subscribe to the service in the angular 2 component, it is always undef...
I am using angular 2 common http that return an Observable, but I face with a problem that my code likes a mesh when I use nested Observable call:   this.serviceA.get().subscribe((res1: any) => {    this.serviceB.get(res1).subscribe((res2: any) =&...
I think I misunderstand how Observables are supposed to be used. I want to put a value in, and when the value changes it should emit the new value. I thought that was what they were for, but all the tutorials and docs don't seem to do this, but a...
I have a block of code where I'm calling observables in a chain like so:  getData().flatMap(results => {    return callNextDataMethod(results); } .flatMap(results2 => {    // next operation and so forth })   Now, I understand that flatMap w...
Goal:  To make a series of synchronous http requests and be able to subscribe to them as one observable stream.  Sample (Not Working):  let query_arr = ['test1','test2','test3']  function make_request(query_arr){      if (quer...
I have built a shared data service that's designed to hold the users login details which can then be used to display the username on the header, but I cant get it to work.  Here's my (abbreviated) code:  // Shared Service @Injectable() export...
I have the following code to get id and then data related to the id.  process(): Observable<any> {     let id: number;     return this.getId().flatMap(         (response: number) => {                 id = response;                 return thi...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.