gpt4 book ai didi

javascript - ng-pluralize "when"绑定(bind)到一个变量

转载 作者:行者123 更新时间:2023-11-29 16:13:10 25 4
gpt4 key购买 nike

我见过的所有 Angular 示例都使用文字“when”参数演示了 ng-pluralize:

<ng-pluralize count="x" when="{'one': 'thing', 'other': 'things'}"></ng-pluralize>

是否可以使用范围变量作为 when 属性?例如:

<ng-pluralize count="x" when="things"></ng-pluralize>

其中 $scope.things 设置为 {'one': 'thing', 'other': 'things'}

我已经试过了,但它没有像我在这里指定的那样工作,但我希望我只是遗漏了一些东西,这是可能的。

最佳答案

所以我刚刚发现,虽然您不能有效地将变量放入 when 属性中(可以,但不会反射(reflect)更新),但您可以这样做:

<ng-pluralize count="modalUsers.length" 
when="{ 'one': '{{ templateConfig.pluralizeConfig.one }}',
'other': '{{ templateConfig.pluralizeConfig.other }}' }">
</ng-pluralize>

然后更新templateConfig 对象。

关于javascript - ng-pluralize "when"绑定(bind)到一个变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22339108/

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