Angular2 allows for the firing of all columns in one click using *ngFor

<tr *ngFor = 'let student of students>
<td  contenteditable="true"  class ='phone' #button>
{{student.phone}}
<i (click)='showbox()' class = '    glyphicon glyphicon-edit'></i>
<input *ngIf='showinput' type="text"   
   class="phone form-control required email "  style="height:38px;">
</td>
</tr>


showbox(){
  this.showinput = true;
}

Whenever the <td> is clicked, it should open an input tag. However, currently, clicking on one column opens it for other columns as well. Can anyone offer some guidance on how to resolve this issue?

Answer №1

Within the component, there is a variable called showinput being declared.

When you click on the td tag, the value of this variable changes correctly. However, since the context is the component, it affects every td within the component.

If you only want the variable to impact a specific td, then use the student variable for the context.

<td  contenteditable="true"  class ='phone' (click)='showbox(student)' #button>{{student.phone}}
         <input *ngIf='student.showinput' type="text" [(ngModel)] = 'student.phone' class="phone form-control required email " style="height:38px;">
    </td>

Component:

showbox(student) {
    student.showinput = true;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is the Prisma model not reachable through Prisma Client?

I'm currently attempting to retrieve a specific property of a Prisma model using Prisma Client. The model in question is related to restaurants and includes a reviews property that also corresponds with a separate Review model. schema.prisma file: // ...

Verify if the array entries match

Within my select element, I populate options based on an array of values. For example: [{ name: 'A', type: 'a', }, { name: 'B', type: 'b', }, { name: 'B', type: 'b', }, { name: &apos ...

Is it feasible to select which modules to be loaded into the application?

Looking for a solution to my problem outlined in the title. For example, I am tasked with creating two separate versions of an app - one for France and one for the UK. In some areas, they require completely different implementations. Is it feasible to sw ...

Pause the execution at specific points within Typescript files by utilizing breakpoints when debugging with an attached debugger in VsCode

My current challenge involves setting up a debugger in VsCode with the attach mode on a Typescript codebase running in a Docker container. Despite successfully attaching the debugger in VsCode and hitting breakpoints, I consistently find myself landing on ...

Could someone assist me in identifying the issue with this logfile and guiding me in the correct direction?

Can someone help me troubleshoot the ng e2e issue in my code? Here's a screenshot of the log file: https://i.sstatic.net/PCrab.png I apologize for the formatting of the package.json file. `package.json` file: { "name": "planning", "version": "0. ...

Are SCSS style sheets being properly included in ng-packagr packaging?

I've been working on developing an Angular component library, packaging the modules for easy NPM installation. However, I took the old-school approach instead of using the CLI like Angular 6 recommends. Despite that, my components function properly wh ...

Setting a timer in NGRX to control the interval between two actions

I am currently working with Angular and NGRX, and I have a requirement to implement a timer between two actions. The timer should start when the first action is triggered and stop when the second action occurs. I need to be able to store this timer in a gl ...

When accessing an Angular 7 page directly through the URL in the browser, it becomes unresponsive. However, the page works perfectly fine when navigating

I've been tackling a poorly developed Angular 7 legacy application and encountering a bizarre issue. There's a component that requires a parameter for email verification, but when the URL is visited directly, it doesn't function as expected. ...

Unraveling the mysteries of an undefined entity

When the variable response is undefined, attempting to retrieve its property status will result in an error: Error: Unable to access property 'status' of undefined const { response, response: { status }, request, config, } = error as A ...

Getting the hang of using and translating typescript .tsx files with jsx in React-native

Recently, I have ventured into the world of React-native after having experience with reactjs+typescript. Wanting to test its capabilities, I decided to set up a simple project. My tool of choice for development is VS Code. After following a basic tutoria ...

Vercel deployment encountered an AxiosError with a status code of 404

I am currently working on an API route called app/api/posts/route.ts, which is responsible for fetching all posts from my database using Prisma ORM. In the localhost environment, the database is hosted on my local PostgreSQL server. However, in production, ...

Help with Material-UI: Passing unique props to a custom TreeItem component

I am trying to pass an argument category to the component CustomTreeItem which uses TreeItemContent. Documentation: https://mui.com/ru/api/tree-item/ import TreeItem, { TreeItemProps, useTreeItem, TreeItemContentProps, } from '@material-ui/lab ...

Determine the dynamic height of content in a TypeScript file

Could you please provide guidance on obtaining the height of the content within this particular div element? For example, I need to calculate the dynamic height of the content. code .html <div class="margin-top-47 margin-horizontal-10" #hel ...

Activating the loader dismiss command will transition the swiper to the current page

Having a swiper and loader makes the scenario very straightforward. The loader is initialized whenever calculations are performed, and after successfully obtaining the result, the loader turns off and swipes to the second slide. <swiper-container #sl ...

Angular Material card layout design

I am looking to create a unique gallery layout for my images using polaroid card-based system with multiple rows and columns. The issue I am encountering is with the mat-card attribute stretching to match the size of portrait images, causing distortion in ...

Tips for successfully passing the dynamic state and setState to a function in typescript

I'm encountering an issue with passing dynamic state and setState into a function using Typescript. Despite trying to use Generics, I am facing complaints from Typescript. Here is the code snippet: const handleSelectTag = (tag: { color: string; labe ...

The image will not appear until the Angular code has been recompiled or the server has been rebooted

I'm at a loss... Scenario An Angular application spanning 2 pages: one page for listing pictures (stored in "assets/picture" directory) one page for uploading pictures, posting them to a node/express API responsible for moving the pictures into th ...

Error in the design of PrimeNg calendar rendering in Angular 2

I have implemented the primeNg module from primefaces in Angular 2 to create a timepicker. It seems to be working, but the design appears broken. Is there something else I need to add to correct the design? Below are the versions of the packages I used: P ...

Error: Trying to access a property of an undefined variable (retrieving 'x')

As a newcomer to the MEAN stack, I am attempting to create some basic posts. However, I keep encountering an error that reads TypeError: Cannot read properties of undefined (reading 'title') when trying to issue a post. The strange thing is, when ...

Tips for utilizing Provide/Inject in Vue.js while leveraging TypeScript

I am currently working with Vue.js and TypeScript along with the vue-property-decorator package. The documentation suggests that I can achieve something like this: import { Component, Inject, Provide, Vue } from 'vue-property-decorator' const s ...