I'm new to Angular and method ng-repeat here is my issue:
I'm making tests to learn, here is what I want to achieve now: loop through a table of table to display some content
My issue is: second ng-repeat only shows the last value.
here is my declaration in the controller:
app.controller("ClientCtrl", function($scope){
$scope.ClientSections = [
{title: 'Titre 1', element:
[{name: 'Toto', name: 'Contenu 1', name: 'Contenu 2', name: 'Contenu 3'}]
},
{title: 'Titre 2', element:
[{name: 'Titi', name: 'Contenu 2'}]
},
{title: 'Titre 3', element:
[{name: 'Titre 1', name: 'Contenu 3'}]
}
];
});
here is my pug template
element(ng-repeat="ClientSection in ClientSections")
h2 {{ClientSection.title}}
item(ng-repeat="Client in ClientSection.element")
p {{Client.name}}
That is because your element
object is an array with only one json
in it, update your element
to become:
element:
[{name: 'Toto'}, {name: 'Contenu 1'}, {name: 'Contenu 2'}, {name: 'Contenu 3'}]
And of course the same must be done to all of your objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With