This repository was archived by the owner on Oct 2, 2019. It is now read-only.
This repository was archived by the owner on Oct 2, 2019. It is now read-only.
Refactor features into sub-directives #402
Closed
Description
As per my comment here: #327 (comment)
I think I would like to see all the features get split out into their own respective directives instead of cramming them all together in one giant one. This way (in the future) if you don't want a feature you can compile your codebase without it (in theory anyway). At the very least it would help make the testing and scope of each directive much easier to deal with and improve the overall API.
How would this work?
uiSelect.directive('uiSelect', function(){
// doesn't contain multiselect or tagging functionality (theoretically)
});
uiSelect.directive('multiple', function(){
return {
restrict: 'A',
require: [ 'multiple', '?uiSelect'], // making it optional in case some other directive uses a 'tagging' attribute
controller: function() {
return {...}; // shareable api goes here
},
link: function($scope, $element, $attrs, controllers) {
var ctrl = controllers[0];
var uiSelectCtrl = controllers[1];
if (!uiSelectCtrl) return;
// add multi-select features here
}
};
});
uiSelect.directive('tagging', function(){
return {
restrict: 'A',
require: [ 'tagging', '?uiSelect', '?multiple'], // making it optional in case some other directive uses a 'tagging' attribute
controller: function() {
return {...}; // shareable api goes here
},
link: function($scope, $element, $attrs, controllers) {
var ctrl = controllers[0];
var uiSelectCtrl = controllers[1];
if (!uiSelectCtrl || !multipleCtrl) return;
// We can now use uiSelectCtrl to communicate and initialize
$attrs.$observe('tagging', ...);
$attrs.$observe('taggingTokens', ...);
// etc, etc
}
};
});
Metadata
Metadata
Assignees
Labels
No labels