加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – ng选项,禁用行

发布时间:2020-12-17 08:38:58 所属栏目:安全 来源:网络整理
导读:是否可以使用ng选项,它将呈现到禁用行基于标准? 这个: select ng-options="c.name group by c.shade for c in colors" 也许可能变成这样的东西: select ng-options="c.name group by c.shade for c in colors | disabled(c.shade)" 并且让我们说通过一个
是否可以使用ng选项,它将呈现到禁用行基于标准?

这个:

<select ng-options="c.name group by c.shade for c in colors">

也许可能变成这样的东西:

<select ng-options="c.name group by c.shade for c in colors | disabled(c.shade)">

并且让我们说通过一个过滤器,可以返回disabled =’disabled’所有颜色的shade =“黑暗”

<select>
   <optgroup label="dark">
      <option value="0" disabled="disabled">black</option>
      <option value="2" disabled="disabled">red</option>
      <option value="3" disabled="disabled">blue</option>
   </optgroup>
   <optgroup label="light">
      <option value="1">white</option>
      <option value="4">yellow</option>
   </optgroup>
 </select>
接受的答案是正确的,但现在应该更新,因为这是固定的角度,参见 docs of ng-options,它也包含一个例子( https://docs.angularjs.org/api/ng/directive/ngOptions#example)。

我使用Angular 1.5和这对我工作:

视图

< select ng-model =“$ ctrl.selectedItem”ng-options =“item as item.label disable when item.disabled for item in $ ctrl.listItems”>

控制器

vm.items = [{id:’optionA’,label:’Option A’},{id:’optionB’,label:’Option B(recommended)’},{id:’optionC’,label:’Option C(Later)’,disabled:true}];vm.selectedItem = vm.items [1];

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读