Last active
December 27, 2015 01:29
-
-
Save thomasboyt/7245265 to your computer and use it in GitHub Desktop.
backbone v. ember v. angular: actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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