Skip to content

Instantly share code, notes, and snippets.

@bbrown
Last active December 2, 2015 23:23
Show Gist options
  • Save bbrown/7612305db52f1cb37090 to your computer and use it in GitHub Desktop.
Save bbrown/7612305db52f1cb37090 to your computer and use it in GitHub Desktop.
Angular directive for Smart-Table to make its internal objects available
// FROM https://github.com/lorenzofox3/Smart-Table/issues/235#issuecomment-64878223
angular.module("app").directive("expose", function()
{
return {
require:"stTable",
link: function(scope, element, attr, ctrl)
{
if (attr["expose"].length > 0)
{
if (!scope.$parent.smartTable)
{
scope.$parent.smartTable = {};
}
scope.$parent.smartTable[attr["expose"]] = ctrl;
if (!scope.$parent.smartTableState)
{
scope.$parent.smartTableState = {};
}
scope.$parent.smartTableState[attr["expose"]] = ctrl.tableState();
}
else
{
scope.$parent.smartTable = ctrl;
scope.$parent.smartTableState = ctrl.tableState();
}
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment