Bob Kiefer Bob Kiefer - 1 year ago 107
AngularJS Question

How to sync multi-select dropdown list of US states with ammap United States map using AngularJS

I'd like to use AmMap and AngularJs to implement a map of the United States and a multi-selection dropdown list of states (with checkboxes in the list) for a mobile web application. The user should have the option to select one or more states using either the map or the dropdown list. When a state is selected or de-selected by either clicking on the map or using the dropdown list, I'd like both objects to be in sync with each other. Has anybody done something similar to this? I am new to AngularJS and am looking for advice or an example.
Thanks in advance!

Answer Source

I would suggest wrapping your usage of AmMap in a directive. You can see an example here: How to use ammap in angularjs. You should do what you can to make your directive reusable, then potentially post it on GitHub since it looks like there is no existing directive out there (at least that I could find). Check out a directive tutorial like this one to learn more about how to make a quality directive.

As for the dropdown issue, check out the AngularJS Dropdown Multiselect directive. My generic advice to you as a new AngularJS developer: always check to see if a widget you need is publicly available already. If not, make a directive to do it in a reusable way.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download