I would like to create an associative array in angular2 but havent found out a way yet
This is what i have tried
onSubmit(){
let inputfield:any[] = [];
for(var i=0; i<this.inspectionform.value["inputfileds"].length; i++){
if(this.inspectionform.value["inputfileds"][i]["input"] != ""){
//here i need help
inputfield.push( i : this.inspectionform.value["inputfileds"][i]["input"]) //this returns a syntax error
}
}
} So what am actually looking forward to have is to pass a key and value to the array
Something like
1:sdbhd//pass this to the array
In the for loop i have tried
//inside the for loop
let arrayval = [];
arrayval.push(this.inspectionform.value["inputfileds"][i]["input"])
arrayval.push(i)
inputfield.push(arrayval);
This creates a new object every time of this nature
0:njnf
1:1(value of i)