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

151
Views
Ocultar parte del componente en el componente de inicio Angular

este es el archivo ts de un componente de acordeón que he llamado en la página de inicio. Sin embargo, quiero usar el parámetro showOnHome para mostrar solo los que tienen un valor booleano verdadero. ¿Cómo puedo hacer eso?

 @Component({ selector: "app-faq", templateUrl: "./faq.component.html", styleUrls: ["./faq.component.css"], }) export class FaqComponent implements OnInit { data = [ { id: 1, question: "question1", answer: [ "answer here", ], bullet: false, showOnHome: true, }, { id: 2, question: "question2", answer: [ "answer2", ], bullet: false, showOnHome: false, },]``` Called On Home Page as: ``` <app-faq></app-faq> ```
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Puede filtrar la lista de elementos antes de mostrarlos haciendo algo como:

 const filteredData = data.filter(d => d.showOnHome);
about 4 years ago · Juan Pablo Isaza Report

0

Puede crear un parámetro para su componente llamado showHome y filtrarlo internamente.

 export class FaqComponent { @Input() showHome: boolean = false; filteredData; data = [ { id: 1, question: "question1", answer: ["answer here"], bullet: false, showOnHome: true }, { id: 2, question: "question2", answer: ["answer2"], bullet: false, showOnHome: false } ]; ngOnInit() { console.log(this.showHome); if (this.showHome) { this.filteredData = this.data.filter((question) => question.showOnHome); } else { this.filteredData = this.data; } } }

Llamado en la página de inicio como:

 <app-faq [showHome]="true"></app-faq>

EDITAR: Cree un ejemplo simple de cómo funciona esto. https://codesandbox.io/s/focused-nash-dlgsl?file=/src/app/app.component.html

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!