After I struggled half a day with same problems as the thread creator, I came also to the conclusion, that I need to handle the actions somewhere in the more “upper levels”, meaning routes or controllers.
But … I never read about in the official guides, that the handling of actions should happen in the applications Routes. But for sure, I’ve read, that the data-handling not should happen in the component. If it should not happen in the component, and we should forget controllers since v2.0, maybe the handling should really happen in the Route?
At the moment, I tried different ways:
- inject the
store
in the component and manipulate the model
-array (meaning creating a new record and push it to the model array)
- bubbling up the actions from the component to the controller and …
- injected a service in the controller where the
model
-array gets manipulated
- manipulated the
model
-array within an action of the controller
All of these methods did not trigger an update of the model
data gave to the component.
Actual structure:
App
> Controller A
> Route /x/i
>- SubController B of Controller A
>- - Component "1"
> Route /x/ii
>- SubController B of Controller A
>- - Component "1"
> Route /x/iii
>- SubController B of Controller A
>- - Component "1"
In all of the x
routes, I will do with different topics
:
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
let params = this.store.peekAll('Parameter');
return params.filterBy('topic', 'cri');
}
});
I will then pass the model-array from the Controller
to the Component
:
{{#dt-leasing-params
title='CRI'
model=model
parameter-topic='cri'
parameter-sign="%"
--this is just for the syntax highlighter of discuss}}
{{!-- here is how I bubble the action up to the ctrl --}}
new-param=(action "new-param" "cri")
{{!-- and here is how I send the action to the service, that is injected in the parent controller --}}
createParam=(action "add-dt-param" "cri" target=add-dt-param) as |crtParam|
{{/dt-leasing-params}}