I've got a two-part form, where one page lets a user select via checkbox from several lists. Having made those selections, the user can see a summary of selections, on another page. The user can then return to the checkbox list and check/uncheck as needed.
I can get it to work so the user's selections persist, but then I can't get the output to show up properly on the main page (the summary list). Or, if I get the output to show up nicely with item.name, then I can't get the selections to persist when the user returns to the secondary page's list of checkboxes. Sharing across controllers is NOT the problem, really. The problem here is getting the checkboxes to retain their checked-state when the user returns to the checkbox list. When I output {{checkedCity}}, for instance, I can see everything's in there. I just can't get the checkboxes to reflect this.
This seems to revolve around how the data is entered in the factory: if I use value="item.name" in the checkbox input, then the name string is all that's added to the factory. But I need the id, as well, since that's what I'll be actually sending the api. So if I change to value="item", then I can get the output to look nice, and I get the id -- but then I don't get the persistence if the user revisits the page.
My instinct (which has gotten me nowhere, sadly) is the factory can't see that its contained objects are the same as what's being spit out in the checkbox ng-repeat. I've tried ng-click, ng-checked, and now I'm trying using the webStorage plugin, instead. I've also attempted to cycle through the factory and compare it to the checkbox list.
Here the plunk: http://plnkr.co/edit/akvFJrPP7YtOoNBDS0Hx?p=preview
What's the best way to tackle this? Regardless of how I store the info, the underlying issue remains that I can't seem to get the checkbox list to reconcile with what's being stored, to know that something is checked.
Many many thanks in advance for any help!