ng-repeat 标题属性中的项目

ng-repeat item in title attribute

ng-repeat 内的元素中使用 title 属性时,我无法显示工具提示。

<div ng-repeat="item in ctrl.items">
  <collapsable-panel is-open="true" class="custom-class" title="{{item.name}}">
         @*  other code *@
  </collapsable-panel>
</div>

有了这个我得到了一个错误

Syntax Error: Token '{' invalid key at column 2 of the expression [{{item.name}}] starting at [{item.name}}].

希望知道为什么会发生这种情况。

您需要使用ng-attr绑定标题。

试试这个:

<div ng-repeat="item in ctrl.items">
  <collapsable-panel is-open="true" class="custom-class" ng-attr-title="{{item.name}}">
         @*  other code *@
  </collapsable-panel>
</div>