<table st-table="LIST_ITEMS" st-filtered-collection="filteredCollection" class="table table-striped ng-isolate-scope"> <thead> <tr> <th>Название</th> <th>Тип</th> <th>Індексация в БД </th> <th>Статус</th> <th>Страна</th> <th>Исходные данные</th> <th>Публикация Университета</th> <th>Автор сотрудник</th> <th>Соавторы студенти</th> <th>Публикация студента</th> <th>Соавторы других ВУЗов</th> <th>Соавторы заграничных ВУЗов</th> </tr> </thead> <tbody> <!-- ngRepeat: item in rests --><tr ng-repeat="item in rests" class="ng-scope"> <td ng-bind="item.job_title" class="ng-binding">Тестовая робота</td> <td ng-bind="item.types" class="ng-binding">учебник</td> <td ng-bind="item.indexing" class="ng-binding">да</td> <td ng-bind="item.status" class="ng-binding">национальный</td> <td ng-bind="item.country" class="ng-binding">Украина</td> <td ng-bind="item.output_data" class="ng-binding">тестовые</td> <td ng-bind="item.published_sumdu" class="ng-binding">да</td> <td> <span ng-bind="item.staff[$index].fio" class="ng-binding">PIB1</span> <br> <span ng-bind="item.staff[$index+1].fio" class="ng-binding">PIB2</span> </td> <td><span ng-bind="item.student[$index].fio" class="ng-binding">PIB1</span> <br> <span ng-bind="item.student[$index+1].fio" class="ng-binding">PIB2</span></td> <td ng-bind="item.student_publication" class="ng-binding">да</td> <td><span ng-bind="item.oi[$index].fio" class="ng-binding">PIB1</span> <br> <span ng-bind="item.oi[$index+1].fio" class="ng-binding">PIB2</span></td> <td><span ng-bind="item.fi[$index].fio" class="ng-binding">PIB1</span> <br> <span ng-bind="item.fi[$index+1].fio" class="ng-binding">PIB2</span></td> </tr><!-- end ngRepeat: item in rests --> </tbody> <tfoot> <tr> <td colspan="5" class="text-center"> <div st-pagination="" st-items-by-page="itemsByPage" st-displayed-pages="10" class="ng-isolate-scope"><!-- ngIf: numPages && pages.length >= 2 --></div> </td> </tr> </tfoot> </table> This is the interface itself, tried to output it through another ng-repeat, but then looked into the documentation again and realized that it cannot be used as a loop for nested objects, that is, like this:
<tbody> <tr ng-repeat="item in rests"> <td ng-bind="item.job_title"></td> <td ng-bind="item.types">></td> <td ng-bind="item.indexing">></td> <td ng-bind="item.status">></td> <td ng-bind="item.country">></td> <td ng-bind="item.output_data">></td> <td ng-bind="item.published_univercity">></td> <td ng-repeat="item.staff in rests.item track by item.staff.id"> <span ng-bind="item.staff[$index].fio"></span> </td> <td ng-bind="item.student[$index].fio"></td> <td ng-bind="item.student_publication"></td> <td ng-bind="item.oi[$index].fio"></td> <td ng-bind="item.fi[$index].fio"></td> </tr> </tbody> How can one iterate over the loop and output only 1 property of objects or can it somehow be done when receiving data in the controller?
I will explain the data model: there is an essence “publication”, it has its own attributes, there are entities “student”, “employee”, “co-author of another university”, “co-author of a foreign university”. They are all related to the “publication” of the set-to-set relationship. When I output all the attributes of a publication, I want to put in 1 cell of the table, by the link, output all the names of the objects associated with it, which I received by rest api, and there may be a lot of them in one publication, that is: there will be a cycle for each object in the program, Now with an index in the interface (now output only by the 1st property) when displaying all the full names (these are nested / associated with the main object): ng-bind = "item.staff [$ index] .fio", ng-bind = "item. student [$ inde x] .fio "B ng-bind =" item.oi [$ index] .fio ", ng-bind =" item.fi [$ index] .fio ".
An example of the data obtained in json:
[ {"id":1,"job_title":"Тестовая робота","types":"учебник","indexing":"да","status":"национальный","country":"Украина","output_data":"тестовая","published_univercity":"да","student_publication":"да", "oi": [ {"id":1,"fio":"oi_pib1","name_oi":"name_oi_1"}, {"id":2,"fio":"oi_pib2","name_oi":"name_oi_2"} ], "staff": [ {"id":1,"fio":"PIB1","faculty":"ELIT","department":"computer science"}, {"id":2,"fio":"PIB2","faculty":"ELIT","department":"computer science"} ], "fi": [ {"id":1,"fio":"PIB1","name_fi":"name_fi"}, {"id":2,"fio":"PIB2","name_fi":"name_fi2"} ], "student": [ {"id":1,"fio":"S_PIB1","faculty":"elit","department":"computer science","groups":"it-01"}, {"id":2,"fio":"S_PIB2","faculty":"elit","department":"computer science","groups":"it-02"} ]}, ] I just tried to work and bring to mind only on the 1m embedded object. The controller is simple, here is a piece to get data from the server:
'use strict'; var controllers = angular.module('controllers', []); controllers.controller('RestController', ['$scope', 'RestService', function ($scope, RestService) { $scope.rests = []; RestService.get().then(function (data) { if (data.status == 200) $scope.rests = data.data; }, function (err) { console.log(err); }); } ]);