3

Hello I need to add an input field into my form with a button. Here my code : stackblitz I got some error in my code. I got this in my browser console: Cannot find control with name: '0' and AuditsComponent.html:9 ERROR TypeError: control.registerOnChange is not a function And in my angular server : ERROR in src/app/components/audits/audits.component.ts(50,26): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'.

Thanks for contributing !

3
  • So you want an input field on top of the button? Where do you want to place it? Commented Oct 24, 2019 at 9:41
  • 1
    fixed your stackblitz: stackblitz.com/edit/… what are you trying to achieve Commented Oct 24, 2019 at 9:42
  • Thx @C_Ogoo, I want to have a textarea by default. And when i click on boutton "Ajouter" a textarea will appear under the initial textarea. If you click again on the button another textarea appear under ... Commented Oct 24, 2019 at 9:51

2 Answers 2

2

I'm correcting your code

https://stackblitz.com/edit/angular-hfrx5u

you must install an import in app.module.ts

  1. angular material
  2. import a MatInputModule
  3. for reactive forms input ReactiveFormsModule

     import { FormsModule, ReactiveFormsModule } from '@angular/forms';
     import {MatInputModule} from '@angular/material/input';  
    
     and in NgModule
    
    imports:[ BrowserModule, FormsModule, ReactiveFormsModule, MatInputModule],
    
Sign up to request clarification or add additional context in comments.

Comments

0

Somebody helped me with my error. I corrected it in my stackblitz.

I didn't give a good property for my arrayItems.

Before (incorrect):

arrayItems= []

After (correct):

arrayItems: any[] = [];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.