I am trying to push formgroup in an formArray but it is giving me the error code which is
Argument of type 'FormGroup<{ name: FormControl<string | null>; amount: FormControl<number | null>; }>' is not assignable to parameter of type 'never'.ts(2345)"
Here is how i declared the Array
let recipeIngredients = new FormArray([]);
Initializing the form here
private initForm() {
let recipeName = '';
let recipeImagePath = '';
let recipeDescription = '';
let recipeIngredients = new FormArray([]);
if (this.editMode) {
//getting the recipe
const recipe = this.recipeService.getRecipe(this.id);
//assigning the values coming from recipes
recipeName = recipe.name;
recipeImagePath = recipe.imagePath;
recipeDescription = recipe.description;
if(recipe['_ingredients']){
for( let ingredient of recipe.ingredients){
recipeIngredients.push( // getting error here
new FormGroup({
'name': new FormControl(ingredient.name),
'amount': new FormControl(ingredient.amount)
})
)
}
}
this.recipeForm = new FormGroup({
'name': new FormControl(recipeName),
'imagePath': new FormControl(recipeImagePath),
'description': new FormControl(recipeDescription)
//'ingredients': recipeIngredients
});
}
let recipeIngredients: FormArray = new FormArray([]);[]insideFormArray([]);is of typenever[]. Trylet recipeIngredients: FormArray = new FormArray<any>([]);