Is there a better way to use button-bar as radio input?


I just created a directive to use a button-bar for a radio input.

Here is a working plunker:

This seems to work well, but there are two things I don’t really like about it, that maybe one the Angular gurus out there can help with:

  1. I copied most of the radio directive from the ionic core, (as well as the css). Is there a good way to make this more dry? The only thing I really need to change is the template.

  2. My method requires two directives, one for the radio input itself and one for a wrapper.

And for the Ionic team, any interest for this functionality in the core?


I think you made it a bit more complex than you needed to. How about just using the simple button bar like this:

Sample :

Now, it would likely be advisable to put this in a directive, but it’s not really necessary.


@Calendee Thanks for the suggestion. Somehow I still have it ingrained in my thought process that input comes from form elements.

Here is a directive from your codepen: