Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Pass data from Subscribe to service

$
0
0

@Luxaaa wrote:

Hello!
I want to subscribe to a Service and pass the data to another Service and subscribe it.
I triet the following but the second result is Always undefined.

ngOnInit() {
      this.taskService.getTasks().subscribe(res => {
        this.tasks = res;
        this.loadSubjects();
      });
    }

   
     async loadSubjects() {
          for(let task of this.tasks) {
              this.subjectsService.getSubject(task.subjectId).subscribe(subject => {
                  task.subject = subject;
                  console.log(subject);
              });
          }
      }

The Services are fine. I testet both in single subscribtion. only then i tried to compine them, it failes.
Hope somebody can help me!
Thanks!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>