[英]angular js peity is not working with ng-repeat
for creating a simple pie chart i am using piety . 为了创建一个简单的饼图,我正在使用虔诚 。 that is very much simple .
这非常简单。 and its working fine with js.
和js一起工作正常。
html HTML
<span class='pie' data-peity='{ "fill": ["#1ab394", "#d7d7d7", "#ffffff"]}'>0.52/1.561</span>
and required js-- 并要求js--
$(".pie").peity("pie");
thats it .. works very fine but problem is within angular js ng-repeat. 多数民众赞成它..工作得很好,但问题是在角度js ng-repeat内。
<div ng-repeat='item in data'>
<span class='pie' data-peity='{ "fill": ["#1ab394", "#d7d7d7", "#ffffff"]}'>{{item.start}}/{{item.end}}</span>
</div>
but that is not working. 但那不起作用。
so i thik that may be i need a directive..so i made it.. 所以我觉得我可能需要一个指令......所以我做了..
app.directive('pieChart', function ($timeout) {
return {
restrict: 'A',
link: function (scope, element) {
$timeout(function () {
element.peity("pie")
}, 100);
}
};
});
and html===> 和html ===>
<td><span data-peity='{ "fill": ["#1ab394", "#d7d7d7", "#ffffff"]}' pieChart>0.52/1.561</span></td>
without ng-repeat
but that is also not working for me . 但那也不适合我。 i dont know why.can anybody help me...
我不知道为什么。任何人都可以帮助我......
When you create a directive, the name you specify is in lower camel-case pieChart
. 创建指令时,指定的名称位于较低的camel-case
pieChart
。 When you use it with as an attribute, it must be in kebab-case
, like pie-chart
当你将它作为属性使用时,它必须是
kebab-case
,就像pie-chart
一样
AngularJS normalizes an element's tag and attribute name to determine which elements match which directives.
AngularJS规范化元素的标记和属性名称,以确定哪些元素与哪些指令匹配。 We typically refer to directives by their case-sensitive camelCase normalized name (eg ngModel).
我们通常通过其区分大小写的camelCase规范化名称(例如ngModel)来引用指令 。 However, since HTML is case-insensitive , we refer to directives in the DOM by lower-case forms, typically using dash-delimited attributes on DOM elements (eg ng-model).
但是, 由于HTML不区分大小写 ,我们通过小写形式引用DOM中的指令,通常使用 DOM元素上的划线分隔属性(例如ng-model)。
The JSFiddle from Naren Murali 来自Naren Murali 的JSFiddle
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.