-
Book Overview & Buying
-
Table Of Contents
Learning Yeoman
By :
In Ember.js, controllers allow you to decorate your models with display logic; models have properties that are sent to the server and controllers have properties that do not need to be sent to the server.
The generator will create a controller that will control the edit view; let's add some logic that will handle saving and destroying a model.
Open the app/scripts/controllers/post_edit_controller.coffee file and add the following content:
LearningYeomanCh5.PostEditController = Ember.ObjectController.extend(
needs: 'post'
actions:
save: ->
@get('model').save()
@transitionToRoute 'post', @get('model')
destroy: ->
@get('model').deleteRecord()
@transitionToRoute 'posts'
)The preceding code does the following:
The PostEditController class is defined extending the Ember.ObjectController class
The needs property specifies that this controller depends on the post controller
The actions object declares a save action and a destroy...
Change the font size
Change margin width
Change background colour