Can I and should i pass arrays to components in ember?
For example if I wanted to template something that renders a couple of radiobuttons with labels:
<label for="media">Media</label><input type="radio" name="entry.1602323871" value="media" id="media" />
<label for="guest">Guest</label><input type="radio" name="entry.1602323871" value="guest" id="guest" />
Could I somehow pass an array with this content and loop through it.
Media, media
Guest, guest
It's now a tiny bit easier to get radio-buttons into your project (if you're using ember-cli) by using the ember-radio-buttons addon
Install:
Usage:
Yeah, You can pass anything to components. Just a try to the radio-buttons
Updated (component name should be dasherized)
Working Radio Demo
Upped @selva-G's answer.
I found that using the ButtonGroup Component from Bootstrap-for-Ember is actually cleaner. Here's what I've done:
In my view's template:
In that view's controller (which doesn't necessarily need to be an ArrayController, rather can be a generic Ember Controller):