Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

MdAutocompleteCtrl.select - add val argument #4144

Closed
dkemper01 opened this issue Aug 13, 2015 · 2 comments
Closed

MdAutocompleteCtrl.select - add val argument #4144

dkemper01 opened this issue Aug 13, 2015 · 2 comments

Comments

@dkemper01
Copy link

On the Contact Chips demo, a welcome user experience would be to click a contact and have it automatically added to the list of selected contacts. From what I gather, this may require an additional argument in the select method of the MdAutocompleteCtrl (auto-complete controller, autocompleteController.js).

The new argument I am proposing would simply be "val", representing a single value in the items list, which currently originates from var items = $scope.$parent.$eval(itemExpr) (line 517, autocompleteController.js). The idea being; an ng-click handler could be added to a contact chip md-list-item in the demo such that the auto-complete control would auto-update its collection of items.

@dkemper01
Copy link
Author

This is easily accomplished by modifying the existing pen for the contact chips demo such that ng-click executes a method in the controller that simply adds the selected contact from the collection of all contacts to the contacts collection of the md-contact-chips.

In the markup ...

<md-list-item class="md-2-line contact-item" ng-repeat="(index, contact) in ctrl.allContacts" ng-if="ctrl.contacts.indexOf(contact) < 0" ng-click="ctrl.selectChip(index)">

In the controller ...

self.selectChip = selectChip;

 function selectChip(index) {
      console.log(index);
        self.contacts.push(self.allContacts[index]);
    }

topherfangio added a commit that referenced this issue Sep 1, 2015
After modifying the `<md-toolbar>` directive to allow both
`md-scroll-shrink` and `ng-if`, we accidentally broke support
for also using `ng-controller` as well as some layout problems
due to the transclusion and a wrapping `<div>`. This reverts
those changes but still allows for `ng-if` to work.

Fixes #4144.
topherfangio added a commit that referenced this issue Sep 2, 2015
After modifying the `<md-toolbar>` directive to allow both
`md-scroll-shrink` and `ng-if`, we accidentally broke support
for also using `ng-controller` as well as some layout problems
due to the transclusion and a wrapping `<div>`. This reverts
those changes but still allows for `ng-if` to work.

Fixes #4144. Closes #4423.
@topherfangio
Copy link
Contributor

Please note: my above commit didn't actually do anything with this issue, I simply transposed the digits in the issue number :/

kennethcachia pushed a commit to kennethcachia/material that referenced this issue Sep 23, 2015
After modifying the `<md-toolbar>` directive to allow both
`md-scroll-shrink` and `ng-if`, we accidentally broke support
for also using `ng-controller` as well as some layout problems
due to the transclusion and a wrapping `<div>`. This reverts
those changes but still allows for `ng-if` to work.

Fixes angular#4144. Closes angular#4423.
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