I'm building a dashboard component to allow users to add widgets that expose various metrics of the underlying database. Each widget is a distinct directive. In order to properly size the widget in the dashboard, I need to access a property defined in the directive's template but struggling to find a way to do so.
I'm adding the widget by compiling its directive:
divWidget = $compile("<" + widgetName + " test='3'></" + widgetName + ">")($scope);
This then gets .appended to the dashboard container:
divContainer = $("<div class='cell' style='width:" + w + "px;height:" + h + "px'></div>");
divContainer.append(divWidget);
$(element).append(divContainer);
I need to set the values of "w" and "h", and I'm embedding these attributes inside the widget's directive template:
<div class="widget" my-rows="1" my-cols="3">
The question is, how do I access my-rows and my-cols once the directive has been compiled? I know I could define a service per widget to access the widget's configuration externally, but this seems like massive overhead.
In the example above, I can access the "test" attribute easily enough, but not the "my-rows" or "my-cols".