AngularJS directive with default options. You can use compile function read attributes if they are not set – fill them with default values.
1 2 3 4 5 6 7 8 9 10 | .directive('pagination', ['$parse', 'paginationConfig', function($parse, config) { ... controller: 'PaginationController', compile: function(element, attrs){ if (!attrs.attrOne) { attrs.attrOne = 'default value'; } if (!attrs.attrTwo) { attrs.attrTwo = 42; } }, ... } }); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.