我正在尝试为jquery easy pie charts编写指令。
按照教程,到目前为止这是我的代码..
angular.module('ysf.easyPieChart', []).directive('easyPieChart', function() {
return {
restrict: 'C',
scope: {
percent: '='
},
link: function(scope, elem, attrs) {
support._debug(elem.easyPieChart, 'element value');
support._debug(scope.percent, 'scope value');
//support._debug(this, 'this');
$(elem.easyPieChart).easyPieChart();
}
}
});
这就是我从模板中调用它的方式
<div class='easyPieChart' percent='73'>73</div>
1.它确实画了一个圆圈,但它不应该在哪里。 2.它没有填补我正确的百分比。
chrome控制台给了我这个错误。
TypeError: Cannot call method 'createDocumentFragment' of null
thnakyou。
答案 0 :(得分:1)
自2.0.0版以来,添加了angular directive easypiechart
。
答案 1 :(得分:0)
这是代码的方式,使用elem [0]
调用元素angular.module('ysf.easyPieChart', []).directive('easyPieChart', function() {
return {
restrict: 'C',
scope: {
percent: '='
},
link: function(scope, elem, attrs) {
support._debug(elem.easyPieChart, 'element value');
support._debug(scope.percent, 'scope value');
//support._debug(this, 'this');
$(elem[0]).easyPieChart();
}
}
});