angular-forms

Getting an error: formGroup expects a FormGroup instance. Please pass one in

无人久伴 提交于 2020-01-25 06:54:49
问题 I am trying to use reactive forms for dynamic values added on click of button. I am getting below error: formGroup expects a FormGroup instance. Please pass one in Here is my example: dynamic-reactive-forms I am new to reactive forms . Some code in ts file: let numberOfTiles = document.getElementsByClassName("tiledata").length; if (this.t.length < numberOfTiles) { for (let i = this.t.length; i < numberOfTiles; i++) { this.t.push(this.formBuilder.group({ tabName: ['', Validators.required],

Angular: how to make NgControl react to valueChanges only of the host <input>

跟風遠走 提交于 2020-01-23 18:22:07
问题 I am using a directive on an <input> -element and get a reference to its controls like this: @ContentChild(NgControl) private readonly _inputNgControl: NgControl; But when I listen to model-changes like so: ngAfterContentInit(): void { this._inputNgControl.control.valueChanges .distinctUntilChanged() .subscribe(value => { // ... }); } it appears that this._inputNgControl.control refers not to the input that the directive is sitting on, but to ALL inputs in my parent component (which contains

No provider for NgForm error in dev mode using Angular 4.4.6

我的梦境 提交于 2020-01-23 15:37:50
问题 EDIT: I've discovered what is causing the problem; I'm now looking for a solution as to how to cater for it. NOTE : This issue is happening in dev mode (i.e. not prod, and not using aot) I'm using the "Update" solution from here: https://stackoverflow.com/a/46324043/3164070 To solve an issue with an input in a child component that was not updating the valid flag on the form. It works in a fairly simple test project, however when moving it to our real project, it throws this error: core.es5.js

No provider for NgForm error in dev mode using Angular 4.4.6

旧巷老猫 提交于 2020-01-23 15:37:50
问题 EDIT: I've discovered what is causing the problem; I'm now looking for a solution as to how to cater for it. NOTE : This issue is happening in dev mode (i.e. not prod, and not using aot) I'm using the "Update" solution from here: https://stackoverflow.com/a/46324043/3164070 To solve an issue with an input in a child component that was not updating the valid flag on the form. It works in a fairly simple test project, however when moving it to our real project, it throws this error: core.es5.js

Angular: How to dynamically add FormControl to FormArray on button click

六月ゝ 毕业季﹏ 提交于 2020-01-20 08:43:06
问题 How can I add a formcontrol(option) dynamically in formarray? I want to add in questions formarray. Onbutton click it should display. I'm using angular 7. //ngOnInit creating form ngOnInit() { this.quizForm = this.fb.group({ questions: this.fb.array([]), questions2: this.fb.array([]), }); } //creating formcontrol createItem(): FormGroup { return this.fb.group({ ques: '', }); } //pushing code genField() { this.message = true; this.questions = this.quizForm.get('questions') as FormArray; this

Angular child component ng-invalid

Deadly 提交于 2020-01-15 20:21:08
问题 I'm creating a custom input component that's forms compatible by implementing ControlValueAccessor . This input component is a composition of one or more child inputs, but I'm having trouble getting the ng-invalid CSS class to propagate to the child input element. My custom input component has a template like: <label>Input:</label> <input type="text" [(ngModel)]="value" (blur)="onInputBlur()" /> The class is: private _value: any; public get value(): string { return this._value; } public set

Angular child component ng-invalid

会有一股神秘感。 提交于 2020-01-15 20:20:07
问题 I'm creating a custom input component that's forms compatible by implementing ControlValueAccessor . This input component is a composition of one or more child inputs, but I'm having trouble getting the ng-invalid CSS class to propagate to the child input element. My custom input component has a template like: <label>Input:</label> <input type="text" [(ngModel)]="value" (blur)="onInputBlur()" /> The class is: private _value: any; public get value(): string { return this._value; } public set

Angular child component ng-invalid

人盡茶涼 提交于 2020-01-15 20:16:40
问题 I'm creating a custom input component that's forms compatible by implementing ControlValueAccessor . This input component is a composition of one or more child inputs, but I'm having trouble getting the ng-invalid CSS class to propagate to the child input element. My custom input component has a template like: <label>Input:</label> <input type="text" [(ngModel)]="value" (blur)="onInputBlur()" /> The class is: private _value: any; public get value(): string { return this._value; } public set

Cannot find control with unspecified name attribute in angular 6 form builder

懵懂的女人 提交于 2020-01-05 04:08:10
问题 I got this error message when trying to update the grid table with the HTML file. Here I have used static data for the table to display and imported from other component which displays the primeng table and I have added an update button with a function which redirects to another page for updating of data. The issue is seen in the first line in the HTML file i.e; [formGroup]="myvehicle" I have tried checking with a different form group name but still the issue is same. import { Component,

How to remove the outline mat-form-filed border corner radius

為{幸葍}努か 提交于 2020-01-02 07:09:23
问题 I am using the angular material outline mat-form-field to design a form. I am getting the default mat-form-field outline text-box view with a border corner radius. Is there any way to remove the border corner radius of the outline mat-form-field and convert into a square text box view. I tried to change the default styles of the angular material mat-form-field with the following, but it's not working. //css .mat-form-field-appearance-outline .mat-form-field-outline-start .alignment{ border