Closed Airblader closed 5 years ago
Having given it some more thought I'm not comfortable, for the moment, with maintaining such an addition. It feels like more of a hack and @angular/material should just expose the CVA, I think. If someone needs to use ngqp with mat-select they can copy the directive above into their project.
Just a question about your directive above... what is 'unknown' in the writeValue function?
public writeValue(value: unknown): void {
Also, can you show the usage of the directive?
@broweratcognitecdotcom It's a type in TypeScript, see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-0.html#new-unknown-top-type.
Also, can you show the usage of the directive?
You don't need to explicitly use it, just add the directive to your code and some module and it will apply automatically. :-)
Ok. But I am getting: ERROR TypeError: this.getQueryParamGroup(...)._registerOnChange is not a function.
My code:
createParamGroup() { this.paramGroup = this.queryParamBuilder.group({ zone_id: this.queryParamBuilder.stringParam('zone_id', {emptyOn: this.prefs.filters.zone_id ? this.prefs.filters.zone_id : this.zones[0]}), }); }
template:
How are you using paramGroup
in the template?
What's your idea?
Unfortunately,
mat-select
does not provide a ControlValueAccessor but uses another mechanism instead (see https://github.com/angular/material2/issues/6549). Given the popularity of the library, we should consider providing our own implementation for it similar to what @MrWolfZ did here:https://github.com/MrWolfZ/ngrx-forms/blob/dd557704f5bf99576827ad790a8d4680f40ecb0c/example-app/src/app/material/mat-select-view-adapter.ts#L17
For completeness sake it should be mentioned that this can also be achied using our
ControlValueAccessorDirective
(at least in my quick tests with static options it worked fine).We should probably do this in a separate package and adapt the schematics to detect if @angular/material is installed and then also install this package.
Describe the solution you'd like
A version adapted to our needs: