Reputation: 1670
I am new to Ember and the assignment I am working on is using 1.11 version already. I used to work on Angular and am finding myself confused with some concepts here in Ember. Read that Controller is used for logic and deals with data whereas Component (js) deals with the behavior of component
So, the doubt I have is
1) Where should i be doing my DOM manipulation
2) In case I need to modify/play my json data, after I get from server is controller the right place or the respective component?
Upvotes: 3
Views: 2701
Reputation: 18240
Why do you use such an old version of ember? Current LTS version is 2.4
, and release is 2.6
.
There questions highly changed since ember 1.13
.
To answer you questions:
You should never do DOM manipulation manually. Use the handlebars template for that. If you absolutely have to the right place is only the didInsertElement
hook of the component, or view in earlier ember versions.
The best way to modify your server data is a serializer
! To calculate additional data use computed properties on the model
, component
and controller
.
Generally only use controllers as last choice. There are some use cases where you have to use them, but not many.
Upvotes: 2
Reputation: 18672
1) Where should i be doing my DOM manipulation
If you are able to move this to component (when designing your logic) it would be definitely more appropriate place than controller.
2) In case I need to modify/play my json data, after I get from server is controller the right place or the respective component?
Best solution would be to fire actions from components and those actions should be handled in controller where you can manipulate your JSON that you probably obtain in routes and pass it along to controllers via model.
Upvotes: 3