custom-autocomplete | A custom autocomplete built with angular 4 frame work | Autocomplete library
kandi X-RAY | custom-autocomplete Summary
kandi X-RAY | custom-autocomplete Summary
A custom autocomplete built with angular 4 frame work
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Root path .
custom-autocomplete Key Features
custom-autocomplete Examples and Code Snippets
Community Discussions
Trending Discussions on custom-autocomplete
QUESTION
I have two components called Employee and Form in my application. There are 2 mat-autocomplete: State and City lists in EmployeeComponent. I fill and pass these mat-autocomplete controls to the FormComponent using "formData" parameter:
Employee Component:
html
...ANSWER
Answered 2020-Dec-14 at 00:34First of all, you use 2 mat-autocomplete. That means the same functionality and behavior. In this situation, I prefer to use a reusable component for that part.
html in parent component
QUESTION
In Angular, I have a reusable autocomplete
list and I need to pass the selected option to another component where this custom component is called. However, the custom component is not called directly and there is another component between them as shown below:
ANSWER
Answered 2020-Dec-07 at 08:43In my opinion you should use a shared service in which you should have BehaviourSubject
type observable
. So whenever user will select any value form autocomplerte
so you can pass that selected option to your BehaviourSubject
observable
and then in your another component
you can subscribe to that BehaviourSubject
.
And if you want to use multiple reusable autocomplete
in one component
so while passing each autcomplete's
selected value you can pass a property named type
in which you will be sending your autocomplete
type.
Like you have your function like this
QUESTION
I am currently working on reusable components with custom form field controls.
I have this custom autocomplete control that returns an object as its value, and then my reusable component, using this custom control, passes one of the object properties to my main form as a string. Here is a blitz to check it out:
https://stackblitz.com/edit/my-custom-autocomplete-jlkj9q
This works fine in one direction, control --> reusable-field --> form.
Here is how I update the form value from my reusable component:
...ANSWER
Answered 2020-Feb-08 at 15:52a couple of things...
your form group's default value is overriding the one provided by your form, the
writeValue
method is called at the end of thengOnInit
hook. You can get around this by simply callingsetValue
in your reusable form in a later hookyou're using onPush change detection in your app component in your blitz. This means that only certain things will trigger change detection, and a child component updating a reactive form value is NOT one of them. This is why you're not seeing the change be reflected in your templates. This isn't a big deal if you're just interested in the form value and not in displaying it on screen, but it IS a big deal if you want to display it, as if you remove onPush change detection, you will begin seeing expression changed errors, as a child updating something in the parents template during initialization violates unidirectional data flow. Getting around this is a bit more difficult. The true answer here is that your parent form really should be the one providing the default value.
QUESTION
I have put together a custom autocomplete form field component in stackblitz based on the custom form field tutorial provided by Angular Material. Here it is:
https://stackblitz.com/edit/my-custom-autocomplete
When I serve this project from my local machine, I get the following error:
Error: Can't resolve all parameters for AutoCompleteControlComponent: ([object Object], [object Object], ?, [object Object]).
Basically, every service injected in the constructor fails. Here is the constructor
...ANSWER
Answered 2020-Feb-04 at 15:07Removing the OR operation solved the problem. I changed this:
@Optional() @Self() public ngControl: NgControl | null,
with this line
@Optional() @Self() public ngControl: NgControl,
Nevertheless, the question remains, why stackblitz and my local environment handle this operation differently..
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install custom-autocomplete
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page