brandonhilkert
brandonhilkert

Reputation: 4475

Ember.js - Where to put dropdown options?

I have a field in our DB that's a integer referring to a billing source. It can be 0, 1, 2, 3, or 4. This grew over time b/c originally was just 2 options. We have a Ruby class that handles this on the old frontend, something like this...

  module BillingSources
    Internal = 0
    Other = 1
    Other2 = 2
    Other3 = 3
  end

Where is the appropriate place to put the mapping of IDs to display in Ember.js?

Upvotes: 0

Views: 45

Answers (2)

user156888
user156888

Reputation:

Here is a method I find good for storing static values in EmberJS:

https://github.com/NetworkActionGroup/nagadmin/blob/master/app/initializers/load-static-models.js

Upvotes: 1

Bouke
Bouke

Reputation: 12138

You can put these in an array inside your controller. If you have key-value pairs, you can use an array of objects. Inside your template you would then use optionValueBinding and optionLabelBinding.

Upvotes: 1

Related Questions