Typescript create array with loop dynamically
All you have to do is use the push function of the array in Javascript.
var NAMES = [];
for (let i = 1; i < 100; i++) {
let newName = {
id:i.toString(),
name:"Tony"
};
NAMES.push(newName);
}
ES6 Way:
const getData = () => Array.from(new Array(100), (val, index) => ({
id:index.toString(),
name:"Tony"
};);
Another way of dynamic initialization, if you are not sure about the size of the array-
let list:Array<{_id:string,name:string}> = Array()
Then simply push values using a loop
list.push({_id:'it001',name:'Sam'})