Angularjs 如何从html函数调用中获取元素?

Angularjs 如何从html函数调用中获取元素?,angularjs,Angularjs,我有一个更新多个进度条的功能: $scope.updateExpProgressBar = function(unit) { return ((unit.exp * /*here I need the max width of the progress bar*/) / unit.nextLevel) + "px"; }; HTML示例: <div class="progress-bar"> <div class="progress-bar-v

我有一个更新多个进度条的功能:

$scope.updateExpProgressBar = function(unit) {
        return ((unit.exp * /*here I need the max width of the progress bar*/) / unit.nextLevel) + "px";
    };
HTML示例:

<div class="progress-bar">
    <div class="progress-bar-value" style="width: {{updateExpProgressBar(selectedUnit)}}"></div>
</div>


问题是这些进度条的宽度不同,我不想为它们中的每一个创建一个函数。

为什么不能将最大宽度也传递给函数?另外,我希望进度条的样式具有以外部容器的
%
表示的宽度,这样就很容易在不更改任何代码的情况下更改宽度。将id命名为“progressBar”,创建事件并单击其模板。在与当前元素相对应的
链接
方法中,将有$element对象。@9000,因为它们的某些宽度可能不同。(例如,是否有滚动条)@MikeGrabowski听起来是个好主意。@Elfayer:您可以随意改变容器元素的宽度,并让其子元素div滚动条始终在0%到100%之间变化。