AngularJS ng-repeat - 另一个列表项中的数据列表

时间:2013-11-29 10:09:17

标签: angularjs datalist

我想绑定一个数据列表。但是这个数据列表在另一个列表中。在以下代码中ng-repeat="Menu in Menus"正常运行。但是ng-repeat="TopCat in Menu.TopCategories"无效,它在列表中。

<li ng-repeat="Menu in Menus">
                    <a href="#" class="mainCategoryLink"><img src="~/Images/{{Menu.MenuDetails.ImageUrl}}" />{{Menu.MenuDetails.Category}}</a>
                    <div class="dropdownSection">
                        <div class="dropdownContainer clearfix">
                            <div class="topCategories">
                                <h2 class="fontsize13 blue3">Top Categories</h2>
                                <ul ng-repeat="TopCat in Menu.TopCategories">
                                    <li>Category{{TopCat.MenuDetails.TopCategories.Category}}</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </li>

这是我的课程,我想从topCategories获取数据到ng-repeat="TopCat in Menu.TopCategories"

        IList<TopCategory> topCategories = new List<TopCategory>();
        topCategories.Add(new TopCategory { Id = 1, ImageUrl = "iconMonitor.png", Category = "Cameras" });
        topCategories.Add(new TopCategory { Id = 1, ImageUrl = "iconAppliance.png", Category = "Laptops" });
        topCategories.Add(new TopCategory { Id = 1, ImageUrl = "iconCar.png", Category = "Monitors" });

        IList<LeftMenuResponse> leftMenu = new List<LeftMenuResponse>();
        leftMenu.Add(new LeftMenuResponse { Id = 1, ImageUrl = "iconMonitor.png", Category = "Electronics", TopCategories = topCategories, OtherCategories = otherCategories });
        leftMenu.Add(new LeftMenuResponse { Id = 1, ImageUrl = "iconAppliance.png", Category = "Appliances", TopCategories = topCategories, OtherCategories = otherCategories });
        leftMenu.Add(new LeftMenuResponse { Id = 1, ImageUrl = "iconCar.png", Category = "Auto Parts", TopCategories = topCategories, OtherCategories = otherCategories });

        return leftMenu;

0 个答案:

没有答案