Daeamon
@Daeamon

Как вывести аттрибуты из массива ANGULATJS в ng-repeat?

есть массив:
'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",
                                },
                            ]
                     },....];
});


Есть html:
<body ng-controller="autogenCtrl">
        <section ng-repeat="section in sections">
        </section>
</body>


необходимо вывести в секцию все аттрибуты из массива sections.attributes.
как это сделать?)

Должно получится так:
<section data-type="background" data-speed="10" class="page-image page-a">
</section>
  • Вопрос задан
  • 174 просмотра
Решения вопроса 1
ну...ещё один ng-repeat внутри?
<section ng-repeat="section in sections">
     <div ng-repeat='attribute in section.attributes'>
          {{attribute.name}} {{attribute.content}}
     </div>
</section>
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы