gpt4 book ai didi

javascript - angular js - 选择条件 "comprehension expression"

转载 作者:行者123 更新时间:2023-11-30 08:54:47 27 4
gpt4 key购买 nike

我有一个 Angular 应用程序,它通过两个选择元素将一组对象映射到另一组对象。
进行映射时,映射对象的“映射”属性设置为 true。

<select ng-model='sourceToMap' required='true' ng-options='code.code for code in sourceCodes'>
<select ng-model='targetToMap' required='true' ng-options='code.code for code in targetCodes'></select>

我希望我的选择显示 sourceCodes/targetCodes 中映射属性为 false 的所有项目。像...

ng-options="code.code for code in sourceCodes where code.mapped = false"

如果可能的话,我想避免使用 mappedItems/unmappedItems 集合,因为这看起来真的很恶心

最佳答案

使用过滤器,像这样:

ng-options="code.code for code in sourceCodes | filter:{mapped: false}"

jsFiddle:http://jsfiddle.net/bmleite/T97DN/

关于javascript - angular js - 选择条件 "comprehension expression",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14554203/

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