Hi.
In my Ember controller I have created a regular Javascript object to store the non-persistent data associated with the current route, e.g. The modal buttons, form fields, tabs etc. These values are passed to the modal component. It looks something like this:
modals: {
myModal: {
buttons: [
{text: 'MyButton', action: 'myAction' disabled: true},
{text: 'MyOtherButton', action: 'myOtherAction' disabled: true}
],
tabs: {
{name: 'myTab', colour: 'red'},
{name: 'myOtherTab', colour: 'green'}
},
fields: {
dropdownContact: {
value: 'primaryContact',
options: [
{text: 'Primary Contact', value: 'primaryContact'},
{text: 'Secondary Contact', value: 'secondaryContact'}
]
}
}
}
}
The problem I have is that some of the attributes within this object need setting dynamically depending on the value of computed properties and other values outside the object. I cannot use the “this.get(‘myAttribute’)” functionality because this object is at the top-level. So, I tried making this object the return value of a computed property that depended upon the model, e.g:
modals: Ember.computed('model', function() {
return {***the object above***};
});
However, this causes problems with the stack being exceeded. I tried regular functions but there were issues with this too.
Essentially, I’d just like to know if I’m overcomplicating things here and if so what is the recommended way of creating data objects that can be initialized with dynamic values from elsewhere in the controller, e.g. this.get(‘myAttribute’)?
Any pointers would be greatly appreciated.
Thanks.