Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

material-dropdown-select does not work with reactive forms ngFormGroup, ngControl, ngFormControl #451

Open
Antoniossss opened this issue Dec 3, 2019 · 1 comment

Comments

@Antoniossss
Copy link

I have following markup:

<form *ngIf="testModel !=null" [ngFormModel]="testModel">
    <input [ngFormControl]="testModel.controls['test1']"/>
    <input ngControl="test1"/>
    <material-input ngControl="test1"></material-input>
    <material-dropdown-select [ngFormControl]="testModel.controls['test2']"></materia-dropdown-select>
    <material-dropdown-select ngControl="test2"[options]="[1,2,3,4]"></material-dropdown-select>
</form>

and backcode


    testModel = FormBuilder.controlGroup({
      "test1": ["", Validators.required],
      "test2": ["", Validators.required]
    });
    testModel.controls['test2'].value;
    print( testModel.controls['test2']);

I have added directrives like


    coreDirectives,
    formDirectives,
    materialInputDirectives,

With that basic setup I got exception
dart_sdk.js:98521 EXCEPTION: Assertion failed: org-dartlang-app:///packages/angular_forms/src/directives/shared.dart:25:7
dir.valueAccessor != null
"No value accessor for () or you may be missing formDirectives in your directives list."

If I comment out first materiald-dropdown-select i got

"No value accessor for (test2) or you may be missing formDirectives in your directives list."

model is created in component constructor so lifecycle should not be an isse here .
Commenting out both dropdowns makes at least inputs work almost as expected (binding is only from input to model, updaing model does not update other inputs)

What am I doint wrong? It works with plain Angular + TS.

@giorgiofran
Copy link

You have to add also "MaterialDropdownSelectComponent" and "MaterialInputComponent" in your directives list

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants