-
Notifications
You must be signed in to change notification settings - Fork 3.4k
mdChip : onDelete event on Chips #3190
Comments
This would be awesome. In the mean time you can just do this: |
If you need to get the chip to remove in your ng-click function, just use $chip as parameter |
Nice it works ! Thanks :) |
Thats all nice and good. However, the Delete key will still delete chips and the click handler will not be executed. I had to use a watch on the chips collection to deal with it properly. |
Yes, for now the only way to invoke a callback on chips change is to watch length of chips's ngModel (( |
@davthu can you post the solution to deal with the delete key ? i wnat to make only one of the chips unable to be deleted. |
This is basicly what we do. Watching the chips collection for changes in size and then finding the the diff (the removeChip function is not included here for simplicity): $scope.$watchCollection('chips', function(newVal, oldVal) {
// A chip has been removed if oldVal is greater in size than newVal
if (angular.isArray(oldVal) && oldVal.length > newVal.length) {
// Find the item(s) in oldVal that does
// not exist anymore in newVal.
var diff = oldVal.filter(function(a) {
return newVal.filter(function(b) {
return a === b;
}).length == 0
});
if (diff.length == 1) {
removeChip(diff[0]);
}
}
}); |
Users have requsted a way to be notified when a chip is removed from the list. closes #3190
Users have requsted a way to be notified when a chip is removed from the list. closes #3190
Users have requsted a way to be notified when a chip is removed from the list. closes angular#3190
Hi,
I have noticed there is a parameter onAppend parameter to the Chips component allowing me to know when a new element is added.
However, I can't see any way to get notified when an element is deleted from the Chips.
Would it be possible to have a similar parameter to be able to know when an element has been removed ?
The text was updated successfully, but these errors were encountered: