Last active
January 1, 2016 23:29
-
-
Save khepin/8216893 to your computer and use it in GitHub Desktop.
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
/** | |
* This defines a simple widget | |
*/ | |
function simpleWidget(){}; | |
simpleWidget.$tags = [ | |
{name: 'widget', value: {width: 1, height: 1}} | |
]; | |
/** | |
* This defines a more complex one that depends on other services | |
*/ | |
function complexWidget(serviceA) {}; | |
simpleWidget.$inject = ['serviceA']; | |
simpleWidget.$tags = [ | |
{name: 'widget', value: {width: 4, height: 2}}, | |
//... | |
] | |
/** | |
* The widget manager receives ALL services that were tagged as "widgets" | |
*/ | |
function widgetManager(widgets, $scope) { | |
// Here widgets would contain 'simpleWidget' and 'complexWidget' | |
for (var i = 0; i < widgets.length; i++) { | |
// Display the widget | |
} | |
} | |
widgetManager.$inject = ['$scope'] | |
widgetManager.$inject.$tags = 'widget' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment