Angularjs 如何在指令中使用绑定?

Angularjs 如何在指令中使用绑定?,angularjs,angularjs-directive,angularjs-ng-repeat,Angularjs,Angularjs Directive,Angularjs Ng Repeat,在我的ng repeat中,我有一个名为update的指令,它采用repeat的当前索引。如何将索引值传递给指令 以下是我的标记的外观: <ul> <li ng-repeat="article in articles"> <span class="btn" update="{{ $index }}">update</span> <span class="btn" ng-attr-update="{{

在我的ng repeat中,我有一个名为update的指令,它采用repeat的当前索引。如何将索引值传递给指令

以下是我的标记的外观:

<ul>
    <li ng-repeat="article in articles">
         <span class="btn" update="{{ $index }}">update</span>
         <span class="btn" ng-attr-update="{{ $index }}">update</span>
    </li>
</ul>
当我运行上面的代码时,它记录为未定义。指令()上的Angular docs表示,使用ng attr作为属性的前缀可以完成此任务。但这并没有发生。我检查了我的DOM,当我使用
ngattr-=“{{$index}}”
作为属性的前缀时,它不会将其编译为仅
=“value”


我有什么遗漏或做错了吗

尝试将update=“{$index}}”更改为
update=“$index”
这应该可以正常工作。也许试着做一把小提琴和大家分享。嘿,我的坏朋友。成功了。我使用的是1.0.8版。angular网站上的下载链接给了我1.0.8而不是1.1.x。谢谢你,伙计。
angular.module('magazine')
.directive('update', function() {
    return {
        restrict: 'A', // restricting it only to attributes
        link: function(scope, element, attrs) {
            console.log(attrs.update);
        }
    }
})