javascript - Grouping objects from multiple arrays? -


i grouping child objects parent objects. have short working example on plunker

it works fine, , understand principle of nesting objects in 1 array. use 2 different scope arrays. company(parent) - workers(child) example:

$scope.parent = [{id: 1, name: "nike", productof:"usa"}] $scope.child = [{ id:1, firstname:"john", lastname:"doe" },                 { id:2, firstname:"john2", lastname:"doe2" },                 { id:3, firstname:"john3", lastname:"doe3" } ] 

i've tried on own, read lot of articles, didn't find need.

can give me hint do, or link article? thank you!

anyway, must have mapping field company in workers array, can use use filter in ng-repeat.

$scope.workers = [         { id:1, companyid:1, firstname:"john", lastname:"doe" },         { id:2, companyid:2, firstname:"john2", lastname:"doe2" },         { id:3, companyid:3, firstname:"john3", lastname:"doe3" }, 

html:

<div ng-repeat="worker in workers | filter:{companyid:company.id}"> 

see example on plunker


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -