I have this angular2 typescript array
part of my angular file
export class ParametersForm {
myForm: ControlGroup;
systemParameters: AbstractControl;
arr: number[];
constructor(fb: FormBuilder) {
this.myForm = fb.group({
"realisations" : [""],
"numConstSteps" : [""],
"timeHorizon": [""],
"continuationStep" : [""],
"continuationStepSign" : [""],
"numberOfModelParameters" : [""],
"systemParameters" : [],
"param" : [""],
"netLogoFile" : [""],
"numberOfModelVariables" : [""],
"restrictOperator" : [""],
"liftOperator" : [""],
"xInitial" : [""]
});
this.arr = [];
this.systemParameters = this.myForm.controls["systemParameters"];
}
addToArray(event, value: any): void {
if (event.which === 13) {
this.arr.push(value);
(<Control>this.systemParameters).updateValue("");
}
}
deleteItem(value: any): void {
let pos = this.arr.indexOf(value);
this.arr.splice(pos, 1);
console.log(this.arr);
}
onSubmit(form: any): void {
console.log(this.arr);
form.systemParameters = this.arr;
console.log("your submitted value:", form);
}
}
you can see arr:number[]
the way i read it, it says, this arr is an array of type number - expects numbers in it
then how come i can enter a string in it?
here is a plunker showing this (check in console after you press enter in input field)
is that normal or?