Last active
August 29, 2015 14:01
-
-
Save paulwsmith/dee0e5cbb57711fde66d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// FOLLOWING LINES ARE PREPENDED VERBATIM TO THE FILE BY SERVER --> | |
(function(pluginName, plugin) { | |
var wizehive = null; | |
var angular = null; | |
plugin.currentPluginName = pluginName; | |
// <-- END SERVER PREPENDING | |
// DUMP YOUR JS CODE HERE - sample plugin code: --> | |
plugin.controller('Data', function($scope) { | |
// my plugin logic | |
}) | |
.controller('Tasks', function($scope) { | |
// my plugin logic | |
}) | |
.register('AwesomePlugin', { | |
templateUrl: 'home', | |
property: 'value' | |
}); | |
// <-- END CUSTOM CODE DUMP | |
// FOLLOWING LINE IS APPENDED VERBATIM TO THE FILE BY SERVER --> | |
})("$pluginName", plugin); // $pluginName is output as a string with the actual name by the server | |
// <-- END SERVER APPENDING |
This file contains hidden or 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
angular.module('wizehive') | |
.service('whTemplateCache', ['$templateCache', function($templateCache) { | |
return { | |
get: $templateCache.get | |
}; | |
}]); | |
plugin.controller = function(name, locals) { | |
if (locals.indexOf('$templateCache') !== -1) { | |
// replace it with 'whTemplateCache' | |
} | |
angular.controller(wizehive.currentPluginName + '-' + name, locals); | |
}; | |
plugin.register = function(name, whatever) { | |
// do something with wizehive.currentPluginName | |
}; | |
plugin.directive = function(name, settings) { | |
if (settings.controller) { | |
settings.controller = wizehive.currentPluginName + settings.controller; | |
} | |
if (settings.template) { | |
settings.template = sanitizeFunction(settings.template); | |
} | |
angular.directive(wizehive.currentPluginName + name, settings); | |
}; | |
angular.module('wizehive') | |
.directive('whController', { | |
scope: { | |
'whController': '@' | |
}, | |
link: function(scope) { | |
var ctrlName = getPluginName() + scope.whController; | |
var template = '<div ng-controller="' + ctrlName + '"></div>'; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment