AngularJS에 JustGauge에 대한 지시문을 만들려고합니다. 내 HTML보기는 다음과 같이이다 :angularjs에서 지시문 생성의 게시 링크에있는 요소를 찾을 수 없습니다.
<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는 잘 작동하지만 두 번째 console.log는 0을 반환합니다. 또한 anglejs를 처음 사용하기 때문에이 문제를 해결할 수 없습니다!
Angular 이전에 jQuery가 포함되어 있습니까? –
@MarkRajcok 예, JQuery와 관련되어 있다면 오류가 발생해야한다고 생각합니다. 그건 그렇고, Justgauge는 jQuery가 필요하지 않습니다. – alisabzevari