Questions tagged angular-forms

Explore the latest questions and answers asked by our top developers.

Angular removing Validators.min from form control validation

I have a form with 2 fields: select dropdown (2 option): with validation, without validation an input amount field depending on the first dropdown I have validators on the 2nd field: Validators.required, Validators.min(0.1). Im trying to use clearValidators() to remove the validation but it only removes the required but not the min(0.1) How do I […]

Add form controls to dynamically loaded data in Angular

In my angular project, there is a CSV uploader in which we get JSON data eg:- 0:{name:"test1";email:"[email protected]";phone:"12345"}, can we attach this data to an angular reactive form Source: Angular Questions

By Ashik T M
Published
Categorized as angular, angular-forms Tagged ,

Angular Form validation values asssign to interface

Here I’m having simple form as <form [formGroup]="loginform"> <input type="text" formControlName="EmailId"/> <input type="text" formControlName="password"/> <button [disabled]="!loginform.valid" (click)="ValidateUser()"></button> <form> My Ts code as loginform!:FormGroup; Here im mentioned my validation as ngOnInit(): void { this.loginform=this.fb.group({ EmailId:[”,[Validators.required]], password:[”,[Validators.required] }) } Geing values as get f(): { [key: string]: AbstractControl } { return this.loginform.controls; } Here is my Interface […]

By Md Gosoddin
Published
Categorized as angular, angular-forms Tagged ,

A contact form in angular is crashing with error Error: NG0201: No provider for NgControl found in NodeInjector

I used an interface for the form inputs in an angular project, I have imported the interface in the contact.component.ts file and imported FormsModule in the app.module.ts there are no compilation errors but the contact page does not show when I try to view it. I would appreciate helpful responses. I also have issues with […]

How to lazy load a component in Angular which are completely dependent on FormsModule?

Note – I already have 6 components in my HomeComponent of which some of them are based on external libraries and they are working perfectly. I am only facing problem when it comes to lazy load a component heavily based on FormsModule. I want to lazy load my ContactUsComponent without importing ContactUsModule anywhere. My contact-us.module.ts […]

Angular template driven form: input "component" not binding to form

I’m trying to generate form fields dynamically based on some JSON object(config). This said config object contains all the attribute values required for constructing form fields(ex: label, type, placeholder etc). Setup In my parent component: I have a form, under which I have an ngFor, iterating over the config object, trying to generate the fields. […]

By anilkumarggk
Published
Categorized as angular, angular-forms Tagged ,

Template Reference Variable in AngularJS

I created a form in angular 13 and include a input filed like in below. <form> <input type="text" name="name" [(ngModel)]="_name" #_name="ngModel" required> </form> then it gives a error like this, Cannot assign value "$event" to template variable "_name". Template variables strong text are read-only. however I change the template reference variable #_name to #name error […]

By shyamantha
Published
Categorized as angular, angular-forms Tagged ,

Uncaught (in promise): NullInjectorError: R3InjectorError(AppModule)[FormBuilder -> FormBuilder -> FormBuilder]

I have to use my FormsModule & ReactiveFormsModule to only shared.module.ts as importing these modules are increasing main.js bundle size. Consider an example I have module named shared.module.ts in which my FormsModule & ReactiveFormsModule and I want to use this SharedModule in some other module; but Angular compiler is throwing me an error "Uncaught (in […]

how to access from nested form group (the name property as an array)?

I need to access the second formBuilder group section to iterate (name and age property)Im having trouble with how deep the nested elements are. How can I iterate name and age over a div based on its level in the form group this.requestForm = this.formBuilder.group({ formArray: this.formBuilder.array([ this.formBuilder.group({ dept:[”], }), this.formBuilder.group({ formRow: this.formBuilder.array([ this.initSingle(), ]) […]

By ow2code
Published
Categorized as angular, angular-forms Tagged ,

I want to Initialize a second form, both containing an input and retrieve both values

I have a form with a single input that may need to be duplicated, how can I grab the two values when they exist on what I assume is a separate form because the component 1 has 1 input box and component 2(duplicated) has 1 input box maybe this helps: user has one college class […]

By ow2code
Published
Categorized as angular, angular-forms Tagged ,
1 36

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq