0

I tried using ng-repeat value,group1,group2

i'm getting

grp1

grp2

abc

def

value1

value2

I need

grp1

  abc

     valu1                           

grp2

      def

          valu1  

Html:
<ul>
<li ng-repeat="heading in group1"> {{heading}} </li> // heading
<li ng-repeat="subheading in group2"> {{subheading }} </li> // sub heading
<li ng-repeat="val in value"> {{val}} </li> // value
</ul>



JavaScript:

                             $scope.group1 = [grp1,grp2];
                             $scope.group2 = [abc,def];
                             $scope.value = [value1,value2];   
1
  • sounds like you need to remap your data so each top level of your array has nested arrays contained within. Then you can structure html to have ng-repeat within ng-repeat to loop over child arrays. Data shown is far too primitive to provide any mapping assistance. WHat you have displayed now shows no relationships between the 3 arrays in your scope Commented Nov 13, 2013 at 13:03

1 Answer 1

1

The template would not use $scope directly. It would be something like this:

<ul>
    <li> {{ keys[0] }}</li> // heading
    <li> {{ keys[1] }}</li> // sub heading
    <li> {{ result }}</li>  // values
</ul>

Scope is implied in the template and {{ }} are used for interpolation.

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

5 Comments

OMG. actually keys[0], keys[1], result are in for loop so i'm geting only one value, so please review the code
Please review the modified code i'm getting only one value In the Box // heading Sales Package // sub heading ssssssssssssss // values it is not repeating
what array do you want to repeat? I'm very unclear on what you are trying to render. Can you provide an example?
now please check the code i modified i need to repeat group1 , group2, value simultaniously
Your 3 ng-repeat are independant so the content of the first ng-repeat will be printed completely before the content of the second ng-repeat. You will need to include them in each other for this to work. Something like <li ng-repeat="x in group1"><span ng-repeat="y in group2"></span></li>

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.