我在Jquery中有一個條形圖,我想要在角度上重新創建。該圖只是程式化的div這就是寬度設置爲父的比例如下圖所示在angular.js中設置div的寬度作爲父級的百分比
$('.item-skills').each(function(){
newWidth = $(this).parent().width() * $(this).data('percent');
$(this).width(newWidth);
});
我希望把這個稱爲bar-graph
指令使用像
<div bar-graph="0.85"></div>
從而會產生DIV這就是寬度是父母的85%
編輯:我發現了一個解決方案在這裏Angularjs adjust width based on parent element width
但'酒吧graph'不會是一個有效的屬性我的解決方案,以creating directives鏈接 – Pete 2014-09-05 13:55:51