We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
forms
When we want to make a simple custom value accessor, according to the docs, we can use DefualtValueAccessor.
the example:
Let's suppose we have app-my-custom-control component
app-my-custom-control
@Component({ selector: 'app-my-custom-control', templateUrl: './my-custom-control.component.html', styleUrls: ['./my-custom-control.component.scss'], }) export class MyCustomControlComponent implements OnInit { constructor(private ngControl: NgControl) {} ngOnInit(): void { //testing code this.ngControl.valueChanges?.subscribe((data) => { console.log(data); }); } }
We can use app-my-custom-control as Value Accessor One if we add ngDefaultControl directive.
ngDefaultControl
@Component({ selector: 'app-default-custom-control', styleUrls: ['./default-custom-control.component.scss'], template: ` <app-my-custom-control [(ngModel)]="value" ngDefaultControl ></app-my-custom-control> `, }) export class DefaultCustomControlComponent implements OnInit { value = '2'; ngOnInit(): void { setInterval(() => { this.value = new Date().toString(); }, 3000); } }
Which works fine. But we have to add ngDefaultControl in all the places we use it.
to avoid duplication, we can add DefaultValueAccessor directive in hostDirectives property like this:
DefaultValueAccessor
hostDirectives
@Component({ selector: 'app-my-custom-control', templateUrl: './my-custom-control.component.html', styleUrls: ['./my-custom-control.component.scss'], hostDirectives: [DefaultValueAccessor], })
Unfortunately, we can't do this because DefaultValueAccessor is not standalone,
So the proposal is to make it standalone.
The proposed solution is to make DefaultValueAccessor directive standalone to be able to put it in hostDirective property
hostDirective
I don't see any alternative besides that use it as it is right now
The text was updated successfully, but these errors were encountered:
Hi, there is already an open issue on this : #48607
Sorry, something went wrong.
yeap you're right. I'll close this one then. I hope we will get it soon
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
No branches or pull requests
Which @angular/* package(s) are relevant/related to the feature request?
forms
Description
When we want to make a simple custom value accessor, according to the docs, we can use DefualtValueAccessor.
the example:
Let's suppose we have
app-my-custom-control
componentWe can use app-my-custom-control as Value Accessor One if we add
ngDefaultControl
directive.Which works fine. But we have to add
ngDefaultControl
in all the places we use it.to avoid duplication, we can add
DefaultValueAccessor
directive inhostDirectives
property like this:Unfortunately, we can't do this because
DefaultValueAccessor
is not standalone,So the proposal is to make it standalone.
Proposed solution
The proposed solution is to make
DefaultValueAccessor
directive standalone to be able to put it inhostDirective
propertyAlternatives considered
I don't see any alternative besides that use it as it is right now
The text was updated successfully, but these errors were encountered: