Questions tagged [controlvalueaccessor]

106 questions
23
votes
1 answer

Inconsistent validation issue in Angular custom component

To show a kind of real world example, let's say that we want to use the @angular/material's datepicker in our application. We want to use it on a lot of pages, so we want to make it very easy to add it to a form with the same configuration…
21
votes
3 answers

Angular: How to temporarily highlight dom elements that have just changed?

Before implementing a solution on my own I would like to know if there is a simple manner to change the style of an element (a brief highlight) when the data bound property value has just change. There are lot of elements in my DOM so I do not not…
Anthony Brenelière
  • 48,644
  • 13
  • 37
  • 50
11
votes
5 answers

Angular Two-Way Data Binding and Watching for Changes in Parent Component

It seems there is no way to watch changes in the parent component when using two-way data binding. I have a custom input component for collecting a tag list. Two-way data binding is setup and working between this component and its parent. // the…
Ben Racicot
  • 4,039
  • 8
  • 42
  • 96
6
votes
2 answers

Is forwardRef mandatory while creating NG_VALUE_ACCESSOR

I have a custom input component which implements ControlValueAccessor with providers declared as follows. It seems to work fine. In all the tutorials I could find on the internet, forwardRef was being used extensively whenever NG_VALUE_ACCESSOR is…
Surya KLSV
  • 1,180
  • 4
  • 16
  • 24
6
votes
2 answers

Angular reactive form custom control async validation

Here is the trick: Have component with implemented ControlValueAccessor interface to be used as custom control. This component used as FormControl inside some reactive form. This custom control has async validator. The problem: Method validate()…
5
votes
2 answers

Passing formControlName into Angular component

I have a reactive form. The setup is similar to this: myForm: FormGroup; this.myForm= new FormGroup({ name: new FormControl("", [Validators.required, Validators.maxLength(15), Validators.pattern('...')]), ... }); I use this…
4
votes
2 answers

How To Use A Directive In A Custom Input With ControlValueAccessor Angular

I've been create a simple custom input component in my angular app use ControlValueAccessor. So, when I want to create a form input element, I don't have to call , only call . I have a problem, when I use , I can use…
Titus Sutio Fanpula
  • 2,834
  • 3
  • 10
  • 24
4
votes
0 answers

How to implement multiple level (nested) component using ControlValueAccessor

I have a complicate form which need 4~5 levels of nested form. I have couple of components, all of them implements ControlValueAccessor and the return type is an object array. Instead of return a FormGroup, is there any way to return a FormArray so…
Neardreams
  • 125
  • 9
4
votes
1 answer

Angular: ControlValueAccessor update to all components who share same formControlName

I hope this image explains what I want to do. So I want to do a custom radio component who share the same formControlName. When a radio is clicked, the rest of the components which share the same formControlName should update with active value. How…
4
votes
0 answers

How to apply [formControl] on dynamically created ControlValueAccessor Component

I have a ImageHandler component which implements ControlValueAccessor. ImageHandler should be dynamically generated in another component and views will be embedded. Inputs and output can be set without any problem. But how to apply formControl on…
amit77309
  • 5,346
  • 4
  • 18
  • 27
3
votes
1 answer

Angular Reactive Form, ControlValueAccessor vs. PropertyBinding

i have some form components which in fact just wrap some parts of a big formular into little pieces. I can imagine two ways to do that: a ControlValueAccessor or s simple PropertyBinding to pass in the FormControl to the…
3
votes
1 answer

How do I create a custom Reactive Form Element?

I'm working with Reactive Forms in Angular and I'm trying to create a custom form element so I can use buttons with my form. I'm trying to follow a tutorial from Alligator.io, but it isn't clear how to integrate this into my component. Currently I'm…
London804
  • 740
  • 1
  • 13
  • 32
3
votes
0 answers

Angular custom material control does not show error when form control is touched programmatically

I've created custom angular material control with ControlValueAccessor implemented. When submitting form, if it's invalid, I touch all the controls to make them show validation errors. For some reason my custom control gets highlighted, but does not…
2
votes
2 answers

angular validation state of a nested ControlValueAccessor is not correctly propagated in parents, how to implement this validation?

I have an issue in an angular 10 app, with the propagation of the state of a formGroup to its parent, at initialization. Issue: at component initialization, the validation state of a sub-form is not correctly propagated in parents of more than one…
2
votes
1 answer

focus event is getting called before writeValue() when using custom directive inside ag-Grid cell Editor

Goal: Make ag-Grid cell editable as a currency control. Approach: Created a custom directive for currency. Created a custom cell editor, which uses that currency directive. Issue: In a normal scenario, on page load, control with directive…
Suyash Gupta
  • 435
  • 5
  • 23
1
2 3 4 5 6 7 8