Skip to content

Instantly share code, notes, and snippets.

@hancheester
Last active October 31, 2019 00:15
Show Gist options
  • Save hancheester/4f448fafc1ce2e83340e0e4f1b2cc607 to your computer and use it in GitHub Desktop.
Save hancheester/4f448fafc1ce2e83340e0e4f1b2cc607 to your computer and use it in GitHub Desktop.
/*
Function to show component border together with component name. It is useful for AngularJS component-based application design.
*/
(function () {
'use strict';
var app = angular.module('app');
app.run(function () {
if (app._invokeQueue) {
app._invokeQueue.forEach(function (item) {
if (item[1] == 'component') {
var componentName = item[2][0];
var componentProperties = item[2][1];
if (componentProperties.templateUrl) {
var templateUrl = componentProperties.templateUrl;
delete componentProperties.templateUrl;
componentProperties.template = '<div style="border-style: 1px solid #a9a9a9;border-radius: 4px;padding: 10px;margin: 10px;"><b>' + componentName + '</b><div ng-include"\'' + templateUrl + '\'"></div></div>';
}
else {
var template = '<div style="border-style: 1px solid #a9a9a9;border-radius: 4px;padding: 10px;margin: 10px;">' + componentName + '<div>' + componentProperties.template + '</div></div>';
componentProperties.template = template;
}
}
});
}
});
})();
@hancheester
Copy link
Author

I should move it to JSFiddle to visualize the result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment