Angular 2 material nested md-list-item

痞子三分冷 提交于 2019-12-03 06:59:25

Ok, figured it out, if someone in future gets stuck like this.

Do no *ngfor on md-list-item, rather do it on div, like this

            <md-list>
                <div  *ngFor="let category of practice_categories">
                    <md-list-item>{{category.category}}</md-list-item>
                    <md-list style="margin-left:30px;">
                          <div *ngFor="let subcategory of category.subcategories">
                            <md-list-item>{{ subcategory.subcategory }}</md-list-item>
                          </div>
                    </md-list>
                </div>
            </md-list>

which produces something like

Hope this helps someone, someday

For Angular 1.0 use this snippet:

<md-list>
    <div ng-repeat="category in categories">
        <md-list-item>{{category.name}}</md-list-item>
        <md-list style="margin-left:50px;">
            <div ng-repeat="subcategory in category">
                <md-list-item>{{ subcategory.name}}</md-list-item>
            </div>
        </md-list>
    </div>
</md-list>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!