Angularjs 指令未正确读取我的ng repeat属性

Angularjs 指令未正确读取我的ng repeat属性,angularjs,angularjs-directive,Angularjs,Angularjs Directive,我有一个进度条动画指令。。我想把它放进去。在这里,我想给指令一个值来设置进度加载的动画。。如果我把数据值={{phase.completion}}放进去,会产生一个错误,它无法读取这样的值 指令 appDirectives.directive('snProgressAnimate', ['$timeout', function ($timeout) { return { link: function (scope, $el) { var val

我有一个进度条动画指令。。我想把它放进去。在这里,我想给指令一个值来设置进度加载的动画。。如果我把数据值={{phase.completion}}放进去,会产生一个错误,它无法读取这样的值

指令

appDirectives.directive('snProgressAnimate', ['$timeout', function ($timeout) {

    return {
        link: function (scope, $el) {

            var value=$el.data('value'),
            $bar = $el.find('.progress-bar');
            $bar.css('opacity', 0);
            $timeout(function(){
                $bar.css({
                    transition: 'none',
                    width: 0,
                    opacity: 1
                });
                $timeout(function () {

                    $bar.css('transition', '').css('width', value + '%');
                })
            })
        }
    }
}]);
HTML

<div class="row progress-stats" ng-repeat="phase in project.phases">
  <div class="col-sm-9">
    <h5 class="name">{{phase.name}}</h5>
    <p class="description deemphasize">{{phase.description}}</p>
    <div data-progressbar data-sn-progress-animate data-value="{{phase.completion}}" class="progress-sm bg-white"></div>
  </div>
  <div class="col-sm-3 text-align-center">
    <span class="status rounded rounded-lg bg-body-light">
      <small><span data-animate-number>{{phase.completion}}</span>%</small>
      </span>
    </div>
  </div>
在第一个指令中加载值的唯一方法是访问传递给该指令的作用域,如下所示

var value = scope.phase.completion;
。。但是我想这不是正确的行为


任何帮助???

data value=“phase.completion”
并使用
var value=scope[attrs['dataValue']在指令中获取该值附言:在链接函数
attrs
scope[attrs['dataValue']]=notavailable.中还需要一个参数。。尽管如此,当使用数据值='phase.completion'时,attrs['value']='pahse.completion'关于
scope[attrs['value']]
呢?您如何在
animateNumber
中读取
phase.completion
呢?只需使用{phase.completion}并使用$el.text()读取元素的文本。替换(//gi它给出了一个错误:多个指令[progressbar,snProgressAnimate]请求上的新/隔离范围:我猜progressbar指令有自己的隔离范围。。因此,对于同一个DOM对象,我不能有两个不同的隔离作用域
return {
    **scope:{value:'='},**
    link: function (scope, $el) {
        **console.log(value);**

        //var value=$el.data('value'),
        $bar = $el.find('.progress-bar');
        $bar.css('opacity', 0);
        $timeout(function(){
            $bar.css({
                transition: 'none',
                width: 0,
                opacity: 1
            });
            $timeout(function () {

                $bar.css('transition', '').css('width', value + '%');
            })
        })
    }
}
return {
    **scope:{value:'='},**
    link: function (scope, $el) {
        **console.log(value);**

        //var value=$el.data('value'),
        $bar = $el.find('.progress-bar');
        $bar.css('opacity', 0);
        $timeout(function(){
            $bar.css({
                transition: 'none',
                width: 0,
                opacity: 1
            });
            $timeout(function () {

                $bar.css('transition', '').css('width', value + '%');
            })
        })
    }
}