Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Ember from 'ember';
- const {
- Controller,
- ArrayProxy,
- computed,
- isBlank,
- isEqual
- } = Ember;
- const DecoratedOptions = ArrayProxy.extend({
- objectAtContent(index) {
- let selectedValue = this.get('selectedValue');
- let value = this.get('content')[index];
- return {
- value,
- selected: isEqual(value, selectedValue)
- };
- }
- });
- export default Controller.extend({
- selectedValue: null,
- options: ['foo', 'bar', 'baz'],
- noValueSelected: computed('selectedValue', {
- get() {
- return isBlank(this.get('selectedValue'));
- }
- }),
- decoratedOptions: computed('{selectedValue,options.[]}', {
- get() {
- let selectedValue = this.get('selectedValue');
- let content = this.get('options');
- return DecoratedOptions.create({ content, selectedValue });
- }
- })
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement