AngularJSでJustGaugeのディレクティブを作成しようとしています。私のhtmlビューは次のようなものです:
<div id="guageContainer" class="row" ng-controller="guageCtrl">
<gauge ng-repeat="ind in indicators" model="ind"></gauge>
</div>
私の指示は次のとおりです。
angular.module("pgHome", [])
.directive("gauge", function ($compile) {
return {
restrict: "E",
scope: { model: "=model" },
compile: function (tElement, tAttrs, transclude) {
tElement.append('<div id="{{model.Name}}"></div>');
return {
post: function (scope, iElement, iAttrs, controller) {
console.log(scope.model.Name);
console.log($("#" + scope.model.Name).length);
var g = new JustGage({
id: scope.model.Name,
value: 348,
min: 120,
max: 400,
title: "test",
label: ""
});
}
};
}
};
});
このディレクティブを含むページをロードすると、JustGaugeは、対応するIDを持つ要素が見つからないというエラーを発生させます。最初のconsole.logは正常に機能しますが、2番目のconsole.logは0を返します。また、angularjsを初めて使用するため、この問題を解決できませんでした。