Skip to content

[(ngModel)] binding breaks if template includes specific element #13886

Closed
@AsherBarak

Description

@AsherBarak

I'm submitting a ... (check one with "x")

[X] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Observed behavior
When implementing ControlValueAccessor and including md-select (from angular-material2) in the template ControlValueAccessor methods are not invoked and banana-binding does not work.

Desired behaviour
When implementing ControlValueAccessor and including md-select (from angular-material2) in the template ControlValueAccessor methods are invoked and banana-binding works.

Steps to reproduce
This plunker contains tow identical components where the only difference is the inclusion of md-select in the template of 'with-select' component. This brakes banana binding as described.

  1. Open plunker at http://plnkr.co/edit/BzgXV2?p=preview
  2. Watch console and note logs for all events emitted from ControlValueAccessor methods on no-select component:
    image
    writeValue(obj: any): void {
      this.val=obj;
                console.log('no-select writeValue: ' + obj);
          };

    registerOnChange(fn: any): void {
        console.log('no-select on change registered');
        this.onChange = fn;
    };

    registerOnTouched(fn: any): void {
      console.log('no-select on touched registered');
        this.onTouched = fn;
    };
  1. Note app.component includes both no-select and with-select components:
    image
    Where the only differences is that with-select has md-select in it's template:
    image
    and yet all ControlValueAccessor methods calls for the with-select component are missing from the log (and binding is not functioning).

See also
angular/components#2609

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions