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

feat(contact-chips): add support for md-on-add/remove/select #10051

Open
recursionbane opened this issue Nov 22, 2016 · 11 comments
Open

feat(contact-chips): add support for md-on-add/remove/select #10051

recursionbane opened this issue Nov 22, 2016 · 11 comments
Labels
P4: minor Minor issues. May not be fixed without community contributions. type: enhancement
Milestone

Comments

@recursionbane
Copy link

recursionbane commented Nov 22, 2016

Actual Behavior:

  • What is the issue? * md-contact-chips do not appear to support md-on-add/remove/select bindings
  • What is the expected behavior? md-contact-chips should inherit functionality from md-chips, which do support these bindigs

CodePen (or steps to reproduce the issue): *

Angular Versions: *

Additional Information:

  • Browser Type: * Chrome
  • Browser Version: * 54.0.2840.99 m (64-bit)
  • OS: * Windows 7 Enterprise
  • Stack Traces: None

UPDATE: md-removable doesn't work, either!

@skapin
Copy link

skapin commented Dec 23, 2016

Up, still not working

@skapin
Copy link

skapin commented Dec 23, 2016

For the one who want to patch it:

Add :

md-on-add="$mdContactChipsCtrl.mdOnAdd()($chip)"\
md-on-remove="$mdContactChipsCtrl.onRemove()($chip)"\

to MD_CONTACT_CHIPS_TEMPLATE in angular-material

(like this)

var MD_CONTACT_CHIPS_TEMPLATE = '\
      <md-chips class="md-contact-chips"\
          ng-model="$mdContactChipsCtrl.contacts"\
          md-require-match="$mdContactChipsCtrl.requireMatch"\
          md-on-add="$mdContactChipsCtrl.mdOnAdd()($chip)"\
          md-on-remove="$mdContactChipsCtrl.onRemove()($chip)"\
          md-autocomplete-snap>\
          <md-autocomplete\

@topherfangio
Copy link
Contributor

@skapin You interested in submitting a PR? This seems like a since/simple/safe addition :-)

@topherfangio topherfangio added - Easy fix P4: minor Minor issues. May not be fixed without community contributions. and removed needs: triage by dev labels Jan 10, 2017
@skapin
Copy link

skapin commented Jan 11, 2017

I can yes, but i need to overcheck it again, (especially if no func. is specified)

@daniymilner
Copy link

Hello!
Can we get a solution of this problem?

@skapin
Copy link

skapin commented Apr 3, 2017

An answer is above, check my previous post :)

@skapin
Copy link

skapin commented Apr 3, 2017

For the glory of satan, I repost updated for easy use :

var MD_CONTACT_CHIPS_TEMPLATE = '\
      <md-chips class="md-contact-chips"\
          ng-model="$ContactChipsCtrl.contacts"\
          md-require-match="$ContactChipsCtrl.requireMatch"\
          md-max-chips="{{$ContactChipsCtrl.maxChips}}"\
          md-on-add="$ContactChipsCtrl.mdOnAdd()($chip)"\
          md-on-remove="$ContactChipsCtrl.mdOnRemove()($chip)"\
          md-autocomplete-snap>\

AND then in the Ctrl :

return {
    template: function(element, attrs) {
      return MD_CONTACT_CHIPS_TEMPLATE;
    },
    restrict: 'E',
    controller: 'ContactChipsCtrl',
    controllerAs: '$ContactChipsCtrl',
    bindToController: true,
    compile: compile,
    scope: {
      contactQuery: '&mdContacts',
      placeholder: '@',
      secondaryPlaceholder: '@',
      contactName: '@mdContactName',
      contactImage: '@mdContactImage',
      contactEmail: '@mdContactEmail',
      mdOnAdd: '&',    /** This is new **/
      mdOnRemove: '&',  /** This is new **/
      contacts: '=ngModel',
      maxChips: '@?mdMaxChips',
      requireMatch: '=?mdRequireMatch',
      highlightFlags: '@?mdHighlightFlags'
    }
  };

Feel free to update and share. I use this code in a redefined ctrl to avoid colision with existing one. I changed some name to post it here as much generic as possible.

@edgartheunready
Copy link

I'd like to upvote this fix. Do we just need a PR put together? I blew 4+ hour on this issue today assuming that md-contact-chips conformed to the same interface as md-chips (because I didn't know there was a difference.) Especially since on the documentation md-chips and md-contact-chips are presented on the same demo page: https://material.angularjs.org/latest/demo/chips

This is all coming from a newby to this project.

@batsauto
Copy link
Contributor

batsauto commented Aug 4, 2017

In my opinion, switching to angular material >= 1.1.2 fixes this issue. Maybe I don't completely understand but I think this is resolved.

@tux1337
Copy link

tux1337 commented Dec 29, 2017

I can confirm the issue still persists with v1.1.5; would be great if it would be fixed.
md-contact-chips should have the same functionality than md-chips

@Splaktar
Copy link
Member

Splaktar commented Mar 4, 2018

Yes, please put a PR together from the above and we'll try to get it merged.

@Splaktar Splaktar changed the title md-on-add/remove/select not working with md-contact-chips feat(contact-chips): add support for md-on-add/remove/select Mar 13, 2018
mikepsinn added a commit to QuantiModo/quantimodo-android-chrome-ios-web-app that referenced this issue Oct 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P4: minor Minor issues. May not be fixed without community contributions. type: enhancement
Projects
None yet
Development

No branches or pull requests

9 participants