Since I have this use case right now I was wondering if it is a good idea to add this as a feature in the future.
Basically the user may delete chips but at the same time the user should not be able to add chips by just typing stuff and pressing enter as I have a custom form for that.
Probably the correct thing would have been to separate user input from chips altogether and introduce a layered component which deals with a default input, custom user input, or custom user autocomplete, but that's probably too big a change and will break a lot of implementations (well, all).
What we could do now, is add a bool property: md-no-input (or somesuch), that will suppress the default input - this would give the read-and-delete only behaviour.
+1.
I use chips to display list of contacts. The list is predefined, but it should be an ability to remove a contact from the list.
+1.
+1
+1
+1
+1
Relatively easy to do right now if you want to write a simple directive to disable the child input element.
How about the other way around?
predefined list in which a user shouldn't delete existing items, but be able to add new ones?
Should I open this as a separate issue?
+1
+1
+1
+1
+1
+1
+1
Is there any way to get this behavior now, except of overloading and disable the input that way? To me it seems that read-and-delete-only should be the default behavior for chips.
Easy to do with little risk and no modifications to the library. Just add md-chips-disable-input to the md-chips element and you're done.
module.directive("mdChipsDisableInput", ["$timeout",
function($timeout) {
return {
link: function($scope, $element, $attrs) {
$timeout(function() {
var input = $element.find("input");
input.attr("disabled", "");
}, 100);
}
}
}
]);
The delete-only should be related to #5799
Another way is to use a custom input, like so:
<md-chips ...>
<input disabled />
</md-chips>
I have one md-autocomplete input and three md-chips and need to disable the ability to add a chip with md-autocomplete only.
readonly="true" md-removable="true" doesnt make chips deletable (doesnt display the delete icon on the chip)
readonly="true" md-removable="true" md-enable-chip-edit="false"
will do the trick
Most helpful comment
Another way is to use a custom input, like so: