Skip to content

Instantly share code, notes, and snippets.

@thomasboyt
Last active December 27, 2015 01:29
Show Gist options
  • Save thomasboyt/7245265 to your computer and use it in GitHub Desktop.
Save thomasboyt/7245265 to your computer and use it in GitHub Desktop.
backbone v. ember v. angular: actions
// controller.js
angular.controller('controller', function($scope, $http) {
$scope.submit = function() {
// set $scope.object
$http.put('/api/objects', $scope.object);
};
});
// view.html
<button ng-click="submit">Submit</button>
// view.js
Backbone.View.extend({
initialize: function() {
// set this.model...
_.bindAll(this, 'submit');
},
events: {
'click .submit': 'submit'
},
submit: function() {
this.model.save();
}
});
// view.hbs
<button class="submit">Submit</button>
// controller.js (or route.js, or view.js...)
Ember.ObjectController.extend({
actions:
submit: function() {
this.get('content').save();
}
}
});
// view.hbs
<button {{click "submit"}}>Submit</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment