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

108
Views
Obtengo '[objeto Objeto]' del servicio al componente usando Angular

Por favor, ayuda en el siguiente problema, esta es mi clase modelo. Intenté todas las formas posibles usando .pipe.map() importar {mapa} del método rxjs/operators , pero aún dando [object Object]

 export class AppProfilesDetailsDO { envName?: string; envDesc?: string; envIpAddress?: string; envProfileName?: string; envCrDeployed?: string; envUrl?: string; envAdminConsoleUrl?: string; envDbSchema?: string; envDbUserId?: string; envGisSchema?: string; envPortNo?: number; }

mi clase de componentes

 import { Component, OnInit } from '@angular/core'; import { ProfileserviceService } from './profileservice.service'; import { AppProfilesDetailsDO } from '../models/AppProfilesDetailsDO'; @Component({ selector: 'app-profiledetails', templateUrl: './profiledetails.component.html', styleUrls: ['./profiledetails.component.css'] }) export class ProfiledetailsComponent implements OnInit { appProfileData: AppProfilesDetailsDO[]; constructor(private profileService: ProfileserviceService) { this.appProfileData = [] } ngOnInit() { console.log("In profiledetails component"); this.profileService.getProfileSetUpDetails().subscribe( appProfileData => { this.appProfileData = appProfileData; } ); console.log("Compenent Profile Data: "+this.appProfileData); ==> **in my console it is printing as ==> [object Object] ** } }

Mi componente de servicio

 import { HttpClient } from "@angular/common/http"; import { Injectable } from "@angular/core"; import { Observable } from "rxjs"; import { AppProfilesDetailsDO } from "../models/AppProfilesDetailsDO"; @Injectable({ providedIn: 'root' }) export class ProfileserviceService { BASE_PATH:string = "http://localhost:8080/getProfileSetUpDetails"; constructor(private httpClient: HttpClient) {} httpOptions = { headers: new Headers ({ 'Content-type': 'application/json' }) } appProfileData?: AppProfilesDetailsDO[]; getProfileSetUpDetails() : Observable<AppProfilesDetailsDO[]> { return this.httpClient.get<AppProfilesDetailsDO[]>(this.BASE_PATH); } }

No estoy seguro de dónde está mal. Por favor, ayuda en este problema.

Gracias.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

El problema es esta línea console.log("Compenent Profile Data: "+this.appProfileData); . Está intentando concatenar un objeto con una cadena.

Simplemente cambie esa línea a console.log("Compenent Profile Data: ", this.appProfileData);

Para mayor claridad mira este ejemplo:

 var data = { a: "ali" }; console.log("Compenent Profile Data: " , data); console.log("Compenent Profile Data: " + data);

about 4 years ago · Juan Pablo Isaza Report

0

Si quieres ver el resultado debería ser así

 console.log("Component Profile Data:", this.appProfileData);

de otras formas, intentará registrar el valor concatenado de la cadena con el objeto de resultado , lo cual es imposible

about 4 years ago · Juan Pablo Isaza Report

0

No puede imponer la concatenación entre una cadena y una matriz de objetos como lo hizo así:

 console.log("Compenent Profile Data: "+this.appProfileData);

Entonces, solo use así en su lugar y el problema desaparecerá:

 console.log(this.appProfileData);
about 4 years ago · Juan Pablo Isaza Report
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!