0

I have a simple array which i would want to output it on my list. The array of the first dimension of the array works when i called it, But the second one wasn't able to be detect. What have I done wrong here or have I missed anything? Below are my code:

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

<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>

1 Answer 1

2

the sub-menus must be inside the outer ng-repeat (replaced with div for simplicity):

<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>

otherwise, there is no menus identifier in scope.

Sign up to request clarification or add additional context in comments.

1 Comment

It worked as you have stated, Yes, the menu was out of scope. It helps me. Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.