Using a plain javascript array with AngularStrap’s Selects

The web application I’m currently developing is using https://angularjs.org/ and http://getbootstrap.com/ because, well, I’m an angularjs fan and I suck at layout. Guess the latter is pretty obvious from the theme the site is running right now.

I’ve found 2 options to use angularjs with bootstrap: the first being http://angular-ui.github.io/bootstrap/  and the second http://mgcrea.github.io/angular-strap/ . There are pro’s and cons to both of them and I prefer AngularStrap because it appears to offer the things I need right now. And I think the animations shipped with AngularStrap look better…

I wanted to use the the multi-select button option (http://mgcrea.github.io/angular-strap/#/buttons#selects) with a plain javascript array and noticed there’s no sample for it on the site, so here it is:

In your controller:

$scope.topic = {
  options: ['option1', 'option2', 'option3'],
  selected_options: []
}

In your template:

  

Hope that helps 😉

Leave a Reply

Your email address will not be published. Required fields are marked *