S
S
Sergey Zelensky2015-08-25 08:19:41
typescript
Sergey Zelensky, 2015-08-25 08:19:41

How to fill an array dynamically?

you need to make a collection of elements
like this
TypeScript:

for(var iteration = 1; iteration < this.countElement; iteration++)
{
   this.ElementCollection[iteration]['input'] = new RangeInput(/* параметры*/);
}

this type of construction does not work, tell me the correct syntax and is it possible to fill the array in this way at all

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Zelensky, 2015-08-25
@SergeyZelensky-Rostov

Sergey, look, I figured out how to implement this, but it seems to me that this is redundant and a crutch here:

export class ElementCollection{
  voltage:any;
  amperage:any;
  disamperage:any;
  boxElement:any;
  constructor(i:any,k:any,r:any){
    this.amperage = i;
    this.disamperage = k;
    this.voltage = r;
  }
}

// create input element to parametrs
  export class Agregator {
    wrapperBox:HTMLElement;
    Collection:Array<ElementCollection> = new Array <ElementCollection>();
    constructor()
    {
      for(var i=1; i<5; i++)
      {
        this.Collection[i] = new RangeInputs.ElementCollection(10+i,20,30);
      }
      console.log(this.Collection);	
    }
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question