Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
Pass value to subject service Angular js

i try passa values to child component using subject service, I am based on Documentatio, but somethink is wrong and when a try print data dont show nothing.

i have the navComponent which request api base on select input. When changing select update request and send new data to child page.

Service:



import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';

@Injectable()
export class SearchService {
    // Observable string sources
    private data = new Subject<any>();

    // Observable string streams
    value$ = this.data.asObservable();

    // Service message commands
    setValeu(value: any) {
        this.data.next(value);
    }


}

NavComponent:

 async consultaIndicadores() {
    try {
      this.loading = true
      let con = await this.rq.postRequest(... request ...).toPromise()
      this.loading = false
      

      if (con.status == 200) {

          this.dados = con.data;
          this.search.setValeu(this.dados)

        }

      }
    } catch (error) {
      this.loading = false

      console.log(error)
    }
  }

childComponent


  constructor(private trans: SearchService) {

    this.subscription = trans.value$.subscribe(val => {
      console.log(val);
    })


  }

in each component i seted provider, pass service to constructor etc... I dont know what its wrong. please help me

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!