12. Custom Angular Form Control

  Рет қаралды 7,307

Code Shots With Profanis

Code Shots With Profanis

Күн бұрын

Пікірлер
@yusufs_solos
@yusufs_solos 4 ай бұрын
Amazing video you are angular hero
@aleksandr95
@aleksandr95 Жыл бұрын
Thx for tutorial. It helped me a lot.
@CodeShotsWithProfanis
@CodeShotsWithProfanis Жыл бұрын
Glad to hear that!
@DenisBendrikov
@DenisBendrikov 2 жыл бұрын
I really like the way you show the problem before explaining way to solve it 🔥🔥
@CodeShotsWithProfanis
@CodeShotsWithProfanis 2 жыл бұрын
Glad to hear that! Thanks for your feedback!
@koolvoid
@koolvoid 2 жыл бұрын
Thanks for the tutorial :)
@CodeShotsWithProfanis
@CodeShotsWithProfanis 2 жыл бұрын
You are very welcome! :)
@roberturbanski2797
@roberturbanski2797 Жыл бұрын
Great video. Would be PERFECT if you consider to add tests for such control.
@CodeShotsWithProfanis
@CodeShotsWithProfanis Жыл бұрын
Great suggestion!
@pedrotavares41
@pedrotavares41 Жыл бұрын
Great Video!
@madeOfClay99
@madeOfClay99 3 жыл бұрын
Thank you very much for this video! One question, what about validators? does the parent component handles that? or it should send it to the custom component? Does the custom component needs to be a FormControl? For example, Invalid value -> Who would handle this?
@CodeShotsWithProfanis
@CodeShotsWithProfanis 3 жыл бұрын
You can define the validators in the parent component like you normally do with all the other form elements. If you want to check the validity of the custom component you have to pick the corresponding FormControl instance (from the parent component) and check its validity. As of your question if the custom component should be a FormControl, well no. You can in the Custom Component a form element In the way you prefer. Even a JQuery one. You should of course make sure to update the relevant methods of the ControlValueAccessor. I hope this answers your question :)
@SqoorQurish
@SqoorQurish Жыл бұрын
Hi, any chance to have a list of extension you had on this vedio as seems its helpfull in speedup coding
@kartheeknandini3767
@kartheeknandini3767 3 жыл бұрын
Excellent. I am exactly looking this.
@CodeShotsWithProfanis
@CodeShotsWithProfanis 3 жыл бұрын
Glad it helps 😊
@arpittripathi8089
@arpittripathi8089 3 жыл бұрын
Simple and elaborated explanation, thanks Profanis! I am consufed with providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: CustomInputComponent, multi: true, }, ], We use provider [ ] to declare the Dependency, why we have "CustomInputComponent", please explain.
@CodeShotsWithProfanis
@CodeShotsWithProfanis 3 жыл бұрын
Angular uses tokens for the DI mechanism. To recognize that a component (built-in or a custom one) is compatible with the Angular Forms, it has to provide the token NG_VALUE_ACCESSOR. If we do not do this, then the component will behave like any other component. Let's think of the following; we create a form component and we do not provide the NG_VALUE_ACCESSOR token. We will then have to implement all the needed functionality for the ReactiveForms and the TemplateDriven forms. Having this token though, angular knows how to deal with it. I hope this answers your question.
@arpittripathi8089
@arpittripathi8089 3 жыл бұрын
@@CodeShotsWithProfanis Thanks a lot Profanis! With the above explanation I am able to understand that any CustomFormComponent can be made compatible with Angular Forms by providing NG_VALUE_ACCESSOR token to it. So that CustomFormComponent deals similarly with Angular Foms just like HTML elements ( ... etc) behaves.
@CodeShotsWithProfanis
@CodeShotsWithProfanis 3 жыл бұрын
@@arpittripathi8089 As soon as you have the token for the CustomFormComponent, Angular will recognize it as a Form Component and will try to apply the binding. To make this happen, we have to implement the ControlValueAccessor interface and its methods. I hope this helps :)
@glorieus27
@glorieus27 2 жыл бұрын
Red border in form-field not working if using custom form control & custom error messages, how to solve that? Thanks
@CodeShotsWithProfanis
@CodeShotsWithProfanis 2 жыл бұрын
Do you mind providing a simple stackblitz with this error?
@glorieus27
@glorieus27 2 жыл бұрын
@@CodeShotsWithProfanis already fix few days ago. Thanks
@balajibalamurugan8053
@balajibalamurugan8053 3 жыл бұрын
how to add validations error message in our custom form
@CodeShotsWithProfanis
@CodeShotsWithProfanis 3 жыл бұрын
You can define the validators in the parent component like you normally do with all the other form elements, and then, If you want to check the validity of the custom component you have to pick the corresponding FormControl instance (from the parent component) and check its validity.
@aleksandr95
@aleksandr95 Жыл бұрын
@@CodeShotsWithProfanis In this case, if the input contains an invalid value, the ng-invalid class is not applied to it.
Angular Library: Create an Angular Library And Publish It In NPM
9:18
Code Shots With Profanis
Рет қаралды 14 М.
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Creating custom form controls in Angular (Control Value Accessors)
29:22
Learn How to Use Angular Typed Forms
12:29
Code Shots With Profanis
Рет қаралды 10 М.
The Control Value Accessor | Jennifer Wadella
20:21
ng-conf
Рет қаралды 24 М.
How to Use A Control Value Accessor [Angular Series]
14:23
David Acosta
Рет қаралды 25 М.
Angular Reactive Forms - All Needed Use Cases
15:55
Monsterlessons Academy
Рет қаралды 35 М.
Angular Resource API - Everything You Have To Know (so far)
27:58
Decoded Frontend
Рет қаралды 17 М.
What I learned from this crazy RxJS stream in my Angular app
25:31
Joshua Morony
Рет қаралды 22 М.
Control Value Accessor in Angular [Advanced, 2020]
18:46
Decoded Frontend
Рет қаралды 60 М.
APP_INITIALIZER Token in Angular (Advanced, 2022)
23:56
Decoded Frontend
Рет қаралды 22 М.
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН