Angular Selection Model

Select Something

Without the extra junk

Hello World

Yeah, there are a bunch of grid and table directives out there already. The selectionModel directive is unique in that it is indifferent to how your data is presented and only concerns itself with tracking which items are (and are not) selected.

Want to use a fancy table? Sure. Prefer to work with lists? That works. Just a bunch of divs? That's cool too! selectionModel is just a companion for ngRepeat if you can use ngRepeat to present your data, you can use selectionModel to manage your selection.

How about some demos?

The Basics

Getting up and running is a snap. Include the selectionModel script on your page and add it as a depedency to your angular app.

The selectionModel directive works with ngRepeat, it keys in on a boolean attribute on your collection items (configurable) and assigns a css class to selected items in the view (also configurable). Here's a basic example:


Choose something fancy!

  • {{$index+1}} {{item.label}}

Someone so fancy would choose the {{fancy.selectedItems[0].label | lowercase}}.

That's literally zero lines of code to manage the selection. No click handlers. No view helpers.

Keeping selections in sync...

Is super easy! You can have the same collection power multiple grids or views and never worry about syncing selections.

One Collection, Multiple Grids

Choose something fancy!

  • {{$index+1}} {{item.label}}
Now make it double!
  • {{$index+1}} {{item.label}}

Two {{fancy.selectedItems[0].label}}s?!?! That's too many!

Getting really fancy...

There are tons of ways to configure the selectionModel directive. You can:

The selectionModel directive is built to manage your selections and get out of the way. Use your own list and table styles and don't jump through hurdles to skin complex widgets.

The Kitchen Sink

Here's a more involved example.

# Label Value
{{$index + 1}} {{item.label}} {{item.value}}

And Then...

Still want more? Check out the GitHub repo.