【发布时间】:2015-08-29 19:26:57
【问题描述】:
我正在构建一个带圆圈的进度指示器。圆圈是使用角度指令构建的,并且进度级别作为参数传递给指令,其中使用角度重复提取值。
问题在于,尽管传递了不同的值,但所有进度级别都获得了相同的值。
要设置更新进度级别,我首先尝试使用 jquery .css 函数如下,它为所有进度级别提供相同的值
$(this).find('.ppc-progress-fill').css('transform','rotate('+ deg +'deg)');
然后我尝试将带有 ng-style 的进度嵌入到模板中,这也不起作用,因为所有人的进度级别相同。
<div class="ppc-progress-fill" ng-style="{'transform': 'rotate('+deg+'deg)', '-webkit-transform': 'rotate('+deg+'deg)', '-ms-transform': 'rotate('+deg+'deg)'}"></div>
这是代码的相关部分
AppModule.directive("skillWidget", function(){
var linkFunction = function(scope, element, attributes){
//console.log(attributes);
scope.text = attributes["text"];
scope.percent = attributes["percent"];
percent = parseInt(scope.percent),
deg = 360*percent/100;
//console.log($(this).find('.ppc-progress-fill'));
$(this).find('.ppc-progress-fill').css('transform','rotate('+ deg +'deg)');
//$('.ppc-progress-fill').css('transform','rotate('+ deg +'deg)');
};
return {
restrict: "E",
templateUrl:"views/skillTemplate.html",
link: linkFunction,
scope: {
text: "@text",
percent : "@percent"
}
}
});
这是模板:
<div class="progress-pie-chart"><!--Pie Chart -->
<div class="ppc-progress">
<div class="ppc-progress-fill" ng-style="{'transform': 'rotate('+deg+'deg)', '-webkit-transform': 'rotate('+deg+'deg)', '-ms-transform': 'rotate('+deg+'deg)'}"></div>
</div>
<div class="ppc-percents">
<div class="pcc-percents-wrapper">
<span>{{text}}</span>
</div>
</div>
我错过了什么?
更多信息: 圆形进度条基于此示例http://codepen.io/shankarcabus/pen/GzAfb。
【问题讨论】:
标签: javascript jquery css angularjs