带有AngularJS的JSON:嵌套ng-repeat中的父级

时间:2014-06-24 09:10:54

标签: javascript json angularjs

根据this solution我构建了我的AngularJS应用程序。现在我想在嵌套结构中访问父中的父>值。

我试过这个,但它不起作用:http://jsfiddle.net/BwDAP/

<body  ng-app="WeeklyApp" ng-controller="WeeklyController" >
    <div ng-repeat="week in myData">
       <div ng-repeat="day in week.days">
          {{day.dow}} - {{day.templateDay}}
          <b>Jobs:</b><br/> 
           <ul>
             <li ng-repeat="job in day.jobs"> 
               {{job.name}} 
                 <br />
               <!-- PARENT -->
               parent: {{job.parent.dow}} 
             </li>
           </ul>
       </div>
    </div>
</body>

任何解决方案? THX

1 个答案:

答案 0 :(得分:0)

哈哈,太容易了;-) 以下是解决方案:http://jsfiddle.net/Lm6KZ/

<body  ng-app="WeeklyApp" ng-controller="WeeklyController" >
    <div ng-repeat="week in myData">
       <div ng-repeat="day in week.days">
          {{day.dow}} - {{day.templateDay}}
          <b>Jobs:</b><br/> 
           <ul>
             <li ng-repeat="job in day.jobs"> 
               {{job.name}} 
                 <br />
               <!-- PARENT -->
               parent: {{day.dow}} 
             </li>
           </ul>
       </div>
    </div>
</body>