gpt4 book ai didi

javascript - 如何使用 ng-repeat 索引动态生成的属性列表?

转载 作者:行者123 更新时间:2023-12-03 05:12:13 24 4
gpt4 key购买 nike

所以我有一个字典数组。在字典中,它们具有以下属性:

属性名称属性值产品名称

但是对于每个字典,我都有动态生成的属性名称。这会将索引附加到每个属性(AttributeName0、AttributeName1 等)我这样做的原因是因为我使用的是 ui-grid,它要求列名是唯一的,以便为我引入的每个字典创建一个新列。

字典看起来像这样(在一个名为 resultsToSend 的数组中): enter image description here

我正在尝试使用 ng-repeat 使用这些字典动态创建表单:

<div class="row" ng-repeat="result in resultsToSend">
<div class="col s2">

<md-input-container><label>{{result.AttributeName$index}}</label><input type="number" id="new-day-ARP-input" ng-model="result.AttributeName$index" /></md-input-container>
</div>
<div class="col s4">
<label>Select {{result.ProductName$index}} Material</label>
<md-select ng-model="result.ProductName$index}" md-on-close="clearSearchTerm()" data-md-container-class="selectdemoSelectHeader">
<md-select-header class="demo-select-header">
<input ng-model="searchTerm" type="search" placeholder="Search For Material..." class="demo-header-searchbox md-text">
</md-select-header>
<md-option ng-value="{{mat.ID}}" ng-repeat="mat in Materials | filter:searchTerm">{{mat.Name}}</md-option>
</md-select>
</div>
</div>

但我基本上没有成功地找到如何使用结果。(PropertyNameHere)$index 来访问我试图访问的属性。

有人有什么建议吗?

最佳答案

请在您的 md-select 标记中的 ng-model 中使用 {{result.ProductName + $index}}

关于javascript - 如何使用 ng-repeat 索引动态生成的属性列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41758243/

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