Home > Software design >  How to sovle the error named push is not a function error in Angular
How to sovle the error named push is not a function error in Angular

Time:12-14

I am a newbie Angular developer. I am having a problem with the push method. It has the error ERROR Error: this.signupForm.get(...).push is not a function. I have made references to a lot of websites and other posts in Stackoverflow, but it doesn't work. Here is my code and I also comment which line contains the error in app.component.ts
https://stackblitz.com/edit/angular-ivy-ehs4j8?file=src/app/app.component.css

CodePudding user response:

You need to change the below line.

The form array only has the push method, you were using form control which caused the issue!

Before:

hobbies: new FormControl([]),

After:

hobbies: new FormArray([]), // <- changed here

forked stackblitz

  • Related