Skip to content

Instantly share code, notes, and snippets.

@bcherny
Last active August 29, 2015 14:01
Show Gist options
  • Save bcherny/d3ac22202cb1118a1007 to your computer and use it in GitHub Desktop.
Save bcherny/d3ac22202cb1118a1007 to your computer and use it in GitHub Desktop.
/////////// option 1 //////////////////
// both turntable and the consumer can mutate this object, potentially breaking functionality:
$scope.params = {
limit: 100,
offset: 0,
searchString: '',
sortCriteria: 'country',
sortDirection: 'DESC'
};
$scope.paramMap = {
limit: 'limit',
offset: 'offset',
search: 'searchString',
sortField: 'sortCriteria',
sortOrder: 'sortDirection'
};
////////// options 2 ///////////////////
$scope.params = {
limit: 'limit',
offset: 'offset',
search: 'searchString',
sortField: 'sortCriteria',
sortOrder: 'sortDirection'
};
turntable.set('limit', 100);
turntable.get('limit');
////////// options 3 (original) ///////////////////
$scope.defaults = {
limit: 100,
offset: 0,
search: '',
sortField: 'country',
sortOrder: 'DESC'
};
$scope.paramFactory = function (params) {
return angular.extend({}, $scope.defaults, _.map(params, function () { ... });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment