gpt4 book ai didi

javascript - AngularJS ngClass 表达式和数组组合

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:42:33 24 4
gpt4 key购买 nike

在 AngularUI Bootstrap 模态视图中,我目前在 ng-class 中有以下表达式:

<div class="modal-body mdl-body"
ng-class="{ 'is-msg': vm.message.type == 'msg',
'height-limit': vm.message.hasHeight }">

但我还想传递一组自定义类,如下所示:

ng-class="vm.message.classes"

这是在 Controller 中调用模态的地方:

modalService.open({
type: "okay",
title: "Terms & Conditions",
content: $scope.APISettingData.signup_term_and_condition,
classes: ["h-md", "text-info"],
isHtml: true,
hasHeight: true
});

这两种方式在没有彼此的情况下都有效,但当我尝试将它们结合使用时它们却不起作用。

这有可能吗?请给我一些想法和解决方案。

最佳答案

还有另一种语法看起来像这样

<div ng-class="[custom1, custom2, {'text-danger': isBadJuJu()}]">Some Text</div>

其中 custom1custom2 是 Controller 范围内的变量,{} 是一组表达式,很像您在第一个示例中使用的语法

关于javascript - AngularJS ngClass 表达式和数组组合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39334661/

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