如何通过angularJS中的嵌套键值对正确地重复ng-repeat

Mat*_*ood 8 javascript json angularjs angularjs-ng-repeat

查看实时代码:

Angular JS

我是如何正确地遍历嵌套键值对并正确输出它们如下所示?

我想要的是一棵树就像这样

-touts
  -classes
    -col-12 
    -col-md-12
    -col-lg-12
Run Code Online (Sandbox Code Playgroud)

目前的观点是:

touts
  {"classes":["col-12","col-md-12","col-lg-12"]}
Run Code Online (Sandbox Code Playgroud)

JS:

var currentApp = angular.module('currentApp', []);
currentApp.controller('ACtrl', function($scope){

    $scope.templates = {
        'touts' : [
            {
                'classes' : ['col-12', 'col-md-12', 'col-lg-12' ]
            }
        ]
    };
});
Run Code Online (Sandbox Code Playgroud)

HTML:

<div ng-app="currentApp">
    <div ng-controller="ACtrl">
        <ul ng-repeat="(key, prop) in templates">
            <li>{{key}}</li>
              <li>
                  <ul ng-repeat="class in templates[key]">
                      <li>{{class}}</li>
                  </ul>
            </li>
        </ul>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

has*_*sin 24

你非常接近,我更新了小提琴.http://jsfiddle.net/y9wj6/9/

   <ul ng-repeat="(key, prop) in templates">
        <li>{{key}}</li>
        <ul ng-repeat="val in prop">
            <ul ng-repeat="(o, values) in val">
            <li>{{o}}</li>
                 <ul ng-repeat="i in values">
                      <li>{{i}}</li>
                  </ul
             </ul>
        </ul>
    </ul>
Run Code Online (Sandbox Code Playgroud)