Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/379.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ng尝试输出多维数组时AngularJS中的重复不起作用_Javascript_Html_Arrays_Angularjs - Fatal编程技术网

Javascript ng尝试输出多维数组时AngularJS中的重复不起作用

Javascript ng尝试输出多维数组时AngularJS中的重复不起作用,javascript,html,arrays,angularjs,Javascript,Html,Arrays,Angularjs,我有一个简单的数组,我想把它输出到我的列表中。当我调用数组的第一维数组时,它可以工作,但是第二维数组无法被检测到。我在这里做错了什么或错过了什么?以下是我的代码: Angular.js angular.module( 'theme' , [ ] ).controller('sideController' , function($scope){ $scope.menuName = [ {'name': 'Header' , 'element' :

我有一个简单的数组,我想把它输出到我的列表中。当我调用数组的第一维数组时,它可以工作,但是第二维数组无法被检测到。我在这里做错了什么或错过了什么?以下是我的代码:

Angular.js

angular.module( 'theme' , [
    ] ).controller('sideController' , function($scope){

        $scope.menuName = [
            {'name': 'Header' , 'element' : [
                {'id' : 'template1' , 'template': 'wp-content/themes/dynamictheme/img/template/template1.png'} 
            ]
        }];
    })
;
HTML


  • {{menus.name}

子菜单必须位于外部的
ng repeat
(为简单起见,替换为
div
):


{{menus.name}

否则,范围内没有
菜单
标识符。

如您所述,它工作正常,是的,菜单超出范围。这对我有帮助。非常感谢。
<div id="slideout" ng-app="theme"> 
    <div id="slideMenu" ng-controller='sideController'>
        <ul style="list-style-type: none;">

            <!--- Worked --->

            <li class="active" ng-repeat="menus in menuName">
                <h3><a class="menuItem" id="{{menus.name}}">{{menus.name}}</a></h3>
            </li>

            <!--- Didn't Work --->

            <li id="{{subMenu.id}}" class="draggable" ng-repeat="subMenu in menus.element">
                <img src="{{subMenu.template}}" width="200" />
            </li>
        </ul>
    </div>
</div>
<div class="active" ng-repeat="menus in menuName">
  <h3><a class="menuItem" id="{{menus.name}}">{{menus.name}}</a></h3>
  <div id="{{subMenu.id}}" class="draggable" ng-repeat="subMenu in menus.element">
    <img src="{{subMenu.template}}" width="200" />
  </div>
</div>