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

447
Vistas
How to create a clickable div in angular 14 as in the gmail webpage with when it is clicked i need to show my array of data that is in my ts component

So I have created an inbox component which is under nested routing of the main page , BEFORE that I'M trying to create a page that looks and works similarly like the Gmail web app.

So I need to create a set of three div boxes which is clickable and when one is clicked I need to show one list of array that I have stored in the ts component. what function code should I write that makes the DIV Clickable & when onclick() I need to show the list in the array....

this is my html code(inbox.component.html)

<div class="mails" *ngFor="let obj of mail;index as i" (click)="showMessage()" style="cursor:pointer">
    <div id="test">
        {{obj.id}}
    </div>
</div>

this is my ts component(inbox.component.ts)

import { Component, OnInit } from '@angular/core';
import { RouterLink } from '@angular/router';
@Component({
  selector: 'app-inbox',
  templateUrl: './inbox.component.html',
  styleUrls: ['./inbox.component.css']
})
export class InboxComponent implements OnInit {
       
mail=[] as any;
constructor() { 
  
    this.mail=[
      {
      id:1,
      subject:'test1',
      sender:'op',
      message:'hello, how are you',
      },
      {
      id:2,
      subject:'test2',
      sender:'ak',
      message:'hi,who are you'
      }
  ]
  }
  
  ngOnInit(): void {}
  
showMessage(){}
  
}

this is a screenshot of my webmail app that shows a inbox component

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It's hard to understand fully what you want to achieve but I believe you are looking for *ngIf directive in combination with (click) listener.

https://angular.io/api/common/NgIf

A structural directive that conditionally includes a template based on the value of an expression coerced to Boolean. When the expression evaluates to true, Angular renders the template provided in a then clause, and when false or null, Angular renders the template provided in an optional else clause.

E.g when div is clicked, it turns boolean isShowing true/false which thanks to *ngIf will render the other <div> or not.

Typescript:

isShowing: boolean = true;
<div (click)="isShowing = !isShowing" >click me</div>
<div *ngIf="isShowing"> I am shown if isShowing = true</div>
about 4 years ago · Juan Pablo Isaza Denunciar
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