2017-12-28 6 views
0

ngFor로 만든 테이블이 있는데, td 중 하나에 설명을 입력 할 수있는 입력이 있지만 처음 설명을 입력 할 때 입력 예를 들어, 모두 같은 값을 얻을.각도 2+ [(ngModel)] 배수가 같을 때 동일한 값을 얻음

// Only simulation, because I will get the values from bd, and I can change the value and save on bd again. 
 

 
public description = ['teste1', 'teste2', 'teste3', 'teste4', 'teste5']; 
 
<tr *ngFor="let peopleSkill of people.peopleSkills;"> 
 

 
... 
 

 
<td> 
 
    <p *ngIf="!editSkill">{{description}}</p> 
 
    <input *ngIf="editSkill" type="text" [(ngModel)]="description" placeholder="Digite a descrição"> 
 
</td> 
 

 
... 
 
</tr>

UPDATE : 그것은 지금 일하고있어

= D

public descriptions: string[] = [ 
 
    'Teste1', 
 
    'Teste2', 
 
    'Teste3', 
 
    'Teste4', 
 
    'Teste5' 
 
    ]; 
 

 
<tr *ngFor="let peopleSkill of people.peopleSkills; let description of descriptions; let i=index;"> 
 
... 
 
<p *ngIf="!editSkill">{{descriptions[i]}}</p> 
 
       <input *ngIf="editSkill" type="text" [(ngModel)]="descriptions[i]" placeholder="Digite a descrição" > 
 
       ... 
 
</tr>

+1

아래의 코드와이 문제를 해결했다. 배열로 설명하고 루프의 각 패스에 대해 고유 한 인덱스를 사용하십시오 –

+0

@DeepakKumarTP Tks, 시도 할 것입니다 ... – ESC

+1

[(ngModel)] = "설명"이 잘못되었습니다. 배열의 일부 값을 참조하지 말아야합니다. – kriss

답변

0

나는 당신의 모든 루프를 통해 같은 설명 변수를 사용하는

public descriptions: string[] = [ 
 
    'Teste1', 
 
    'Teste2', 
 
    'Teste3', 
 
    'Teste4', 
 
    'Teste5' 
 
    ]; 
 

 
<tr *ngFor="let peopleSkill of people.peopleSkills; let description of descriptions; let i=index;"> 
 
... 
 
<p *ngIf="!editSkill">{{descriptions[i]}}</p> 
 
       <input *ngIf="editSkill" type="text" [(ngModel)]="descriptions[i]" placeholder="Digite a descrição" > 
 
       ... 
 
</tr>