I have two lists, one with names of "groups" and another with names of "items". It should change contents of list of items when another group is selected.
<div class="headers">
<div id="header-1">Header 1</div>
<div id="header-2 selected">Header 2</div>
</div>
<div class="contents">
<div id="contents-2-1">Сontents 2.1</div>
<div id="contents-2-2">Сontents 2.2</div>
</div>
Currently I've monkey-coded it as two controllers interacting via a service, but it's certainly not an Angular-idiomatic way to do that.
It would be easily solvable if each #header-n contained all the #contents-n-* inside of it, so that scoping rules would be enough to implement required behaviour. The problem is it's impossible to do so.
Another way would be to do it like in an Angular todomvc example via list filtering. Combined quantity of all the items over all groups is high enough to discard this option.
How do I implement such group selection in an idiomatic way?
UPD. The data are looking like this:
var groups = [
{
text: 'group 1',
items: [1, 2, 3]
},
...
];
var items = [
{
id: 1,
text: 'item 1'
},
...
];
contentsdiv. Only one group can be selected at the same time.