角度ng重复的错误值?

时间:2016-02-23 21:04:36

标签: javascript angularjs ng-repeat

循环遍历对象数组中的数组:

<div ng-repeat="benefit in oe.oeBenefits">
    <div class="oeInfo" style="clear: both;">
        <div class="col-md-2 oeCol">
            <img style="height: 160px; padding-top: 20px;" src="ppt/assets/beneTiles/HealthCare.svg">
        </div>
        <div class="col-md-5 oeCol">
            <h1>{{ benefit.benefitName }}</h1>
            <p>Maximum Election Amount: {{ benefit.benefitMax }}</p>
            <p>Contributions to be made: {{ benefit.numberOfContributions }}</p>
            <p ng-show="benefit.employerSeed != null">{{ benefit.employerSeed }}</p>
            <p>link</p>
        </div>              
        <div class="col-md-3 oeCol">
            <p class="oeFeatures" style="font-weight: 800;">Available Features</p>
            <ul>
                <li ng-repeat="Features.value in oe.oeBenefits.Features">{{ Features.value }}</li>
            </ul>            
        </div>  
        <p></p>
        <div class="col-md-12">
            <hr class="naviaHR100">                    
        </div>
    </div>
</div>

我的JSON代码会返回以下内容,但即使发生更改,也无法获取该值。这是返回的JSON:

"oeBenefits": [
{
  "planId": "l0t3AlfKV%2fETUaQd0zZJGA%3d%3d",
  "benefitTypeId": 1,
  "benefitName": "Health Care FSA",
  "isHsaAvailable": false,
  "benefitMin": 0,
  "benefitMax": 3510,
  "numberOfContributions": 12,
  "carryoverAmount": null,
  "isDebitCard": true,
  "is100percent": true,
  "isGracePeriod": true,
  "allowDirectDeposit": true,
  "claimsRunout": 90,
  "employerSeed": "Your employer will contribute additional funds to your benefit",
  "learnMoreUrl": "http://www.naviabenefits.com/participants/benefits/health-care-fsa/",
  "Features": [
    {
      "key": "0",
      "value": "Navia Benefits Card"
    },
    {
      "key": "2",
      "value": "FlexConnect"
    },
    {
      "key": "4",
      "value": "Online claim submission"
    },
    {
      "key": "5",
      "value": "Online card swipe substantiation"
    }
  ]
},

来自对象的所有其他重复数据(s0返回正常,只是这个部分我想要的只是值,而不是键。

3 个答案:

答案 0 :(得分:1)

您应该<li ng-repeat="Features in oe.oeBenefits.Features">{{ Features.value }}</li>而不是<li ng-repeat="Features.value

答案 1 :(得分:1)

这应该可以解决您的问题

Dim Var(1 to 50) as integer

问题在于您的内部循环没有使用正确的数组对象

答案 2 :(得分:1)

你有一个嵌套的ng-repeat,所以在你的情况下你的ng-repeat应该看起来

<li ng-repeat="feature in benefit.Features">{{ feature.value }}</li>