I wrote a directive to JustGage plugin as follows.
function justGage() {
return {
restrict: 'E',
replace: true,
scope: {
id: '@',
value: '='
},
template: '<div id="{{id}}" class="200x160px" style="margin-top: 5vh"></div>',
link: function ($scope, $element) {
var g = new JustGage({
id: $scope.id,
value: $scope.value,
min: 0,
max: 100,
minLabelMinFontSize: 15,
maxLabelMinFontSize: 15,
valueMinFontSize: 40,
valueFontColor: '#ededed'
});
}
};
}
In my controller I assign values to id and gauge value
$element.id = "gauge";
$element.value = $scope.data;
My html is as follows.
<just-gage></just-gage>
Then I get an error as "justgage : no element with id 0". In my directive I added the same id to both template and JustGage object.
How can I solve this issue to render the gauge?
You create a new child scope in your directive, so it doesn't know of the
idandvalueyou assigned in the controller.You can do something like this: