gpt4 book ai didi

css - 如果元素选择器变量为真,AngularJS 添加 css 类

转载 作者:行者123 更新时间:2023-11-28 01:33:58 25 4
gpt4 key购买 nike

我有一个元素选择器指令,我想为所选元素添加一个测试:如果它已存档,我必须添加一个 css 类。

.directive-items-selector{ ng_click: "openItemsSelector( $event )" }
.wrapper
%ui_select.ui-select{ ng: { model: "input.model", disabled: "disabled",
change: "itemSelectModelChanged()" },
search_enabled: "{{ options.searchable }}" }

%ui_select_match.ui-select-match{ items_selector_match: '',
placeholder: "{{ input.placeholder }} ",
allow_clear: "{{ options.clearable }}",
title: "{{ $select.selected.label }}" }
%i.fa{ ng_class: 'icon' }

{{ $select.selected.label }}
{{$select.selected.object.is_archived}}

%ui_select_choices.ui-select-choices{ repeat: "item.id as item in input.filteredItems track by item.id",
refresh: "reloadItems( $select.search )",
refresh_delay: '{{ input.filterDelay }}' }
.item{ ng_attr_title: "{{ ::item.label }}" }
.item-label {{ ::item.label }}
%small.item-details {{ ::item.details }}

.items-selector-actions
%a.pointer.action{ ng: { if: 'linkToModal', click: 'openDetails()', disabled: "!model" }}
{{ 'btn.details' | translate }}
%a.pointer.action{ ng: { if: 'createButton && klassName && !disabled', click: 'createItem()' }}
{{ 'btn.new' | translate }}

如果元素被存档,{{$select.selected.object.is_archived}} 返回 true,我不知道如何添加这个 css 类!任何帮助

最佳答案

你可以像这样使用 ng-class 指令:ng-class="{'class-false' : selected.object.is_archived, 'class-true' : }" https://docs.angularjs.org/api/ng/directive/ngClass

关于css - 如果元素选择器变量为真,AngularJS 添加 css 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50795870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com