material icon indicating copy to clipboard operation
material copied to clipboard

md-chip components with ng-repeat directive not shown on Codepen

Open nick-merrill opened this issue 11 years ago • 39 comments

md-chip components with ng-repeat directive are not shown.

Codepen Example based off of the Static Chips demo

In this case, the chips with the ng-repeat directive are not displayed at all:

<md-chips>
     <md-chip>Normal Static Chip</md-chip>

     <!-- Bug: Chips with ng-repeat directive do not display -->
     <md-chip ng-repeat="i in [1, 2, 3]">ng-repeat Chip</md-chip>
</md-chips>

nick-merrill avatar May 12 '15 18:05 nick-merrill

Same here.

cleever avatar May 12 '15 22:05 cleever

Seeing the same issue.

ttillage avatar May 13 '15 20:05 ttillage

The similar issue exists when <md-chips> component is used inside ng-repeat:

<div ng-repeat="i in [1,2,3]">
  <md-chips>
    <md-chip>Normal Static Chip</md-chip>
  </md-chips>
</div>

Here only the last chip is displayed.

sazonenka avatar Jun 16 '15 22:06 sazonenka

I wonder about that too, I guess it's the directive priority not high enough? Maybe lowering the priority for md-chips or md-chip would help fix this?

pencilcheck avatar Jun 21 '15 05:06 pencilcheck

@sazonenka Same here.

ng-repeat on md-chip unavailable is not a big deal. But md-chips inside ng-repeat not working makes md-chips totally unusable.

cnjsstong avatar Jun 26 '15 16:06 cnjsstong

Actually we have two different issues here. I have opened a new one. Those having issues about md-chips inside of ng-repeat please go to #3482 .

@sazonenka

cnjsstong avatar Jun 30 '15 20:06 cnjsstong

@cnjsstong2 Not totaly unusable. If you want a readonly chip list just set the readonly attribute to "true" on md-chips. Example with custom template:

<md-chips ng-model="ctrl.items" readonly="true">
    <md-chip-template>
        {{$chip.name}}
    </md-chip-template>
</md-chips>     

The md-chips uses ng-repeat internally so $chip is the item from the list you have provided in the ng-model.

kvetis avatar Jul 01 '15 08:07 kvetis

@kvetis Thanks for the workaround!

theblang avatar Jul 10 '15 02:07 theblang

+1 That works.

pencilcheck avatar Jul 28 '15 09:07 pencilcheck

Since we have a workaround for the md-chip repeat issue, and 0.11 will close the md-chips repeat issue, can we go ahead and close this, or should we look at taking the time to support this use-case?

A cursory look seems like it might take quite a bit of refactoring to get this implemented.

@ThomasBurleson @robertmesserle Thoughs?

topherfangio avatar Aug 21 '15 19:08 topherfangio

I still hope that md-chip can work with ng-repeat because it is difficult to set focus with the workaround method.

du6 avatar Sep 17 '15 00:09 du6

@du6 Can you elaborate on the focus issue? I'm not quite sure I understand what you mean.

topherfangio avatar Sep 17 '15 16:09 topherfangio

@topherfangio Problem solved. Please ignore that comment. Sorry for any inconvenience.

du6 avatar Sep 17 '15 17:09 du6

Okay, since we have a workaround, and we haven't gotten any additional feedback, I'm going to go ahead and close this. If someone in the future would like us to reconsider, please post a comment we'll take a look.

topherfangio avatar Sep 18 '15 16:09 topherfangio

with readonly="true" it leaves some space on the chip for the close icon, while with really static chips it doesn't.

LeartS avatar Oct 06 '15 21:10 LeartS

@LeartS same here

AlexVKO avatar Nov 30 '15 05:11 AlexVKO

This is still a problem for me because I am using the chips as a kind of tag editor for images. I can't have static chips because the user can add whatever tags they want.

srukali avatar May 09 '16 14:05 srukali

@srukali Can you not use the ng-model attribute? A Codepen would be very helpful in understanding what you are trying to achieve :-)

topherfangio avatar May 09 '16 15:05 topherfangio

@topherfangio This is a general idea of what I'm trying to do http://codepen.io/anon/pen/XdOxxV

For now I'm turning the editor into a component and then repeat from there.

srukali avatar May 09 '16 15:05 srukali

@srukali Perhaps you can describe it a bit more, but this should actually work. We fixed the bugs that were causing problems with an ng-repeat outside of the chips. This issue was about something like the following:

<md-chips>
  <md-chip ng-repeat="..."></md-chip>
</md-chips>

In your Codepen, it looks like your ctrl.tags variable is an empty array, but the ng-model on the chips, points to ctrl.tags[$index] which will be null/undefined.

Here is an updated one that I think will work as you expect: http://codepen.io/topherfangio/pen/LNqXWK

topherfangio avatar May 09 '16 16:05 topherfangio