Reputation: 8638
I have a angularjs directive that I crafted. It has a defaults object that looks like:
module.constant('tableDefaults', {
hasHeader: true,
paging: {
autoPageSize: true,
count: undefined,
pageSize: undefined
}
});
the directive consumes that constant and merges the options passed in like:
module.directive('ngTable', function ($rootScope, tableDefaults) {
return {
restrict: 'AE',
transclude: true,
replace: true,
require: '^ngModel',
templateUrl: 'common/components/table/views/table.tpl.html',
controller: function(){
// freaks out if removed ...
},
link: function ($scope, $element, $attributes, ctrls) {
if(!$scope.tableOptions) $scope.tableOptions = {}
$scope.tableOptions = angular.copy(tableDefaults, $scope.tableOptions);
}
};
});
I pass options in like:
<div ng-table="{ paging: { count: 100 } }" />
problem is now in my paging object, none of the other options are there. I've been looking at angular.extend
vs $.extend
and realize I could probably use $.extend
to accomplish this but I'm trying to rid my app of jquery. Any suggestions?
Upvotes: 0
Views: 102