0
votes

In my route.hbs I have several components that have computed properties. In my controller I want to see the state of these computed properties. I can't two-way bind the values since they are computed properties. Is it possible to do get the instance of a component inside of a controller and inspect its values?

I have tried Ember.$(#) but this just returns the dom object.

1
You can't do this. This is not how it works. Why do you want to do this?Lux
what you want contradicts with the way ember is designed at the first place. not only you can get components from controller; you cannot get sub-components from within a parent controller. I suspect you have serious design issues; I would highly recommend to review your design.feanor07

1 Answers

1
votes

This answer applies to Ember 1.13 to at least 3.x.

You have a few options for sharing state. I don’t think there’s a way to grab the values from a component in a controller. That would result in very tangled interdependencies.

Some alternate options are: - declare the computed properties in the controller and pass them down to the components, rather than defining them on the component - use a Service for tracking the shared state. - if the computed properties are based on a record, you could add them to the Model itself