D
D
Daeamon2016-01-12 10:27:05
Angular
Daeamon, 2016-01-12 10:27:05

How to output attributes from ANGULATJS array in ng-repeat?

there is an array:

'use strict';
var autogenMod = angular.module('autogenMod', ['ngResource']),
app = angular.module('app', ['autogenMod']);
autogenMod.controller('autogenCtrl', function ($scope, $filter) {
        $scope.sections = [{
                            "tag":"section",
                            "attributes":[
                                {
                                    "name":"data-type",
                                    "content":"background",
                                },
                                {
                                    "name":"data-speed",
                                    "content":"10",
                                },
                                {
                                    "name":"class",
                                    "content":"page-image page-a",
                                },
                            ]
                     },....];
});

There is html:
<body ng-controller="autogenCtrl">
        <section ng-repeat="section in sections">
        </section>
</body>

it is necessary to display all the attributes from the sections.attributes array in the section.
how to do it?)
It should turn out like this:
<section data-type="background" data-speed="10" class="page-image page-a">
</section>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nicholas, 2016-01-12
@Daeamon

well...another ng-repeat inside?

<section ng-repeat="section in sections">
     <div ng-repeat='attribute in section.attributes'>
          {{attribute.name}} {{attribute.content}}
     </div>
</section>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question