如何使md-contact-chips readonly为true

时间:2022-06-11 22:55:56

The md-chips has readonly attribute that disables list manipulation (deleting or adding list items), hiding the input and delete buttons. If no ng-model is provided, the chips will automatically be marked as readonly.

md-chips具有readonly属性,禁用列表操作(删除或添加列表项),隐藏输入和删除按钮。如果没有提供ng-model,芯片将自动标记为只读。

But the md-contacts-chips have no readonly attribute.

但是md-contacts-chips没有readonly属性。

How am I able to disable the remove button for the chips?

我怎么能禁用芯片的删除按钮?

2 个解决方案

#1


3  

I use kind of workaround for this.

我为此使用了一种解决方法。

add ng-class to md-chips:

将ng-class添加到md-chips:

<md-contact-chips ng-class="{'readonly': ctrl.readonly}"

at the controller set readonly variable as You need and add style for .readonly In my case it is:

在控制器设置readonly变量为您所需并为.readonly添加样式在我的情况下它是:

md-chips-wrap {
  box-shadow: none;
  cursor: default;

  button.md-chip-remove {
    display: none;
  }

  .md-chip-input-container md-autocomplete {
    display: none;
    cursor: default;
  }
}

#2


1  

I have create a new "chips-contacts", but list my custom contacts, with readonly

我已经创建了一个新的“芯片 - 联系人”,但是只读了我的自定义联系人列表

<md-chips ng-model="asyncContacts" class="md-contact-chips" md-removable="false" readonly="true">
<md-chip-template>
    <div class="md-contact-avatar">
        <img ng-src="{{$chip.image}}" class="list-product-chip-image" alt="{{$chip.name}}" />
    </div>
    <div class="md-contact-name">
        [{{$index}}] {{$chip.name}}
        ({{$chip.amount}})
    </div>
</md-chip-template>
</md-chips>

#1


3  

I use kind of workaround for this.

我为此使用了一种解决方法。

add ng-class to md-chips:

将ng-class添加到md-chips:

<md-contact-chips ng-class="{'readonly': ctrl.readonly}"

at the controller set readonly variable as You need and add style for .readonly In my case it is:

在控制器设置readonly变量为您所需并为.readonly添加样式在我的情况下它是:

md-chips-wrap {
  box-shadow: none;
  cursor: default;

  button.md-chip-remove {
    display: none;
  }

  .md-chip-input-container md-autocomplete {
    display: none;
    cursor: default;
  }
}

#2


1  

I have create a new "chips-contacts", but list my custom contacts, with readonly

我已经创建了一个新的“芯片 - 联系人”,但是只读了我的自定义联系人列表

<md-chips ng-model="asyncContacts" class="md-contact-chips" md-removable="false" readonly="true">
<md-chip-template>
    <div class="md-contact-avatar">
        <img ng-src="{{$chip.image}}" class="list-product-chip-image" alt="{{$chip.name}}" />
    </div>
    <div class="md-contact-name">
        [{{$index}}] {{$chip.name}}
        ({{$chip.amount}})
    </div>
</md-chip-template>
</md-chips>