gpt4 book ai didi

javascript - 带有子对象的 Ng 选项

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

这是我的数组:

$scope.subscriptions = [
{
currency: {
title: 'Euro',
symbol: '€'
},
licenses: [
{
nrOfLicenses: 5,
price: 500
},
{
nrOfLicenses: 10,
price: 750
}
]
},
{
currency: {
title: 'SEK',
symbol: 'kr'
},
licenses: [
{
nrOfLicenses: 5,
price: 5000
},
{
nrOfLicenses: 10,
price: 7500
}
]
},
]

$scope.selectedSubscription = $scope.subscriptions[0];

我想要一个选择框,您可以在其中选择货币。

我试过这个:

<select ng-model="selectedSubscription.currency" ng-options="currency.title for currency in subscriptions"></select>

它不起作用。这是一个 fiddle :http://jsfiddle.net/HB7LU/10066/

我做错了什么?

最佳答案

您需要像这样更改选择:-

<select ng-model="selectedSubscription.currency" ng-options="sub.currency.title for sub in subscriptions"></select>

这是更新的 fiddle http://jsfiddle.net/gbsLa4wh/

关于javascript - 带有子对象的 Ng 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27959971/

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