material icon indicating copy to clipboard operation
material copied to clipboard

md-chips that include an autocomplete throw an exception when they are readonly.

Open ddimitrop opened this issue 11 years ago • 12 comments

Codepen example

http://codepen.io/ddimitrop/pen/OVNjbd

There is an exception in dev console

TypeError: Cannot read property 'registerSelectedItemWatcher' of undefined at MdChipsCtrl.configureAutocomplete (angular-material.js:11978) at angular-material.js:12242 at angular.js:16299 at completeOutstandingRequest (angular.js:4924) at angular.js:5312

in line

https://github.com/angular/material/blob/786b0ed3652b7460c2c802efa1aa79972bd96f5d/src/components/chips/js/chipsDirective.js#L255

there is no guarantee that the compiled chipInputTemplate will include an actual auto-complete just because it was in the source

ddimitrop avatar May 13 '15 20:05 ddimitrop

I'm having this issue all of a sudden and I'm not exactly clear as to why. Is there a way to get around this for the time being?

cognitronic avatar Jun 05 '15 18:06 cognitronic

+1

stewones avatar Jun 17 '15 17:06 stewones

+1

Millen31 avatar Jun 18 '15 22:06 Millen31

anyone have a temporary workaround until this is fixed?

ryanovas avatar Jun 25 '15 18:06 ryanovas

+1

Kyoss79 avatar Jun 26 '15 15:06 Kyoss79

+1 but I have a workaround for now..

  1. ditch the readonly property for md-chips
  2. use your readonly var for the autocomplete's ng-disabled
  3. use a custom md-chip template
  4. add an ng-hide to the md-chip-remove button with your readonly var

charliewynn avatar Jul 02 '15 15:07 charliewynn

+1

yochayme avatar Aug 12 '15 13:08 yochayme

+1

rafidka avatar Sep 20 '15 01:09 rafidka

@rafidka Are you still seeing this in 0.11? We pushed a fix in https://github.com/angular/material/commit/3e8c99455832a3e457a1de00afd1601c11d55c5e.

topherfangio avatar Sep 21 '15 09:09 topherfangio

@topherfangio I think I am still on 0.10, I will try the new one and let you know.

rafidka avatar Sep 22 '15 11:09 rafidka

@topherfangio sorry for the late response. I tried Angular 0.11 and it indeed solved it. Thanks!.

rafidka avatar Oct 02 '15 18:10 rafidka

For those that end up here searching only...

TypeError: Cannot read property 'some' of undefined at MdChipsCtrl.appendChip

This is caused by an undefined in ng-model

waratah avatar Jan 17 '18 23:01 waratah