Apologies for my poor English, I'll do my best to explain my issue. Here's the problem:
I'm using ngFor on an Input element, but when I enter data, it gets repeated in all the fields and I can't figure out why.
<div *ngFor="let itra of itras; let n=index " class="col-md-4">
<input type="number" name="{{n}}" #{{n}} [(ngModel)]="ihi.Itra[n]" [attr.placeholder]="itras[n]" class="form-control" max="999999">
</div>
import {Ihi} from '../models/ihi';
export class AddDocumentsComponent implements OnInit {
public ihi: Ihi;
public itras = ["1", "2", "3"];
This is the Angular model:
export class Ihi{
constructor(
public _id: string,
public Idoc: string,
public Fech: string,
public Hini: string,
public Hter: string,
public Luga: string,
public Itra: string
){}}
The data is sent to an API built with MEN stack.
var ihiSchema = Schema({
Idoc:{type: Number},
Fech:{type: String},
Hini:{type: String},
Hter:{type: String},
Luga:{type: String},
Itra:[{type: Number,minlength:6,maxlength:6}]},{versionKey: false});
While testing with Postman, the API successfully receives multiple "Itra" parameters, but I'm struggling to achieve the same with Angular. Any help with this issue would be greatly appreciated.