Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

136
Vistas
How to filter JSON inside an angular ionic component?

I'm trying to map and filter a JSON inside a component but I have not succeeded, from the service "data.services.ts" I had no problem, but when taking the data to the component "tab1.page.ts" I couldn't, the usual thing I do is use:

.pipe(
    map((res: any) => {
        return res
    })
);

Tab1.page.ts

import { Component, OnInit } from '@angular/core';
import { DataService } from '../services/data.services';

import { map } from "rxjs/operators";
import { filter } from "rxjs/operators";

@Component({
  selector: 'app-tab1',
  templateUrl: 'tab1.page.html',
  styleUrls: ['tab1.page.scss']
})
export class Tab1Page implements OnInit {

  items = []

  constructor(private dataService: DataService) {}

  ngOnInit(): void {
      this.dataService.getRemoteData().subscribe(data=> {
        this.items = data
      })
  }

}

data.services.ts

import { Injectable, Input } from "@angular/core";
import { HttpClient } from "@angular/common/http";

import { map } from "rxjs/operators";
import { filter } from "rxjs/operators";

@Injectable({
    providedIn: "root"
})
export class DataService {

    constructor(private http: HttpClient) {}

    getRemoteData() {
        return this.http
        .get("https://api")
        .pipe(
            map((res: any) => {
                return res.prosugApi
            })
        );
    }
}

I'm trying:

export class Tab1Page implements OnInit {

  items = []

  constructor(private dataService: DataService) {}

  ngOnInit(): void {
      this.dataService.getRemoteData().subscribe(data=> {
        this.items = data
        return this.items.filter((filter1) => {
          return filter1.sublinea == "SOFA"
        })
        });       
      }
  }

But I have not been lucky.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda