标题属性中的ng-repeat项目

时间:2017-08-09 21:09:47

标签: angularjs angularjs-ng-repeat

ng-repeat内的元素中使用<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}}].

这样我就收到了错误

Pulse::Pulse(const double amplitude,
         const double delay,
         const double width,
         const double freq,
         const Eigen::Vector3d &wavevector,
         const Eigen::Vector3d &field_orientation)
: amplitude(amplitude),
  delay(delay),
  width(width),
  freq(freq),
  wavevector(wavevector),
  field_orientation(field_orientation.normalized())
{
}

Eigen::Vector3d Pulse::operator()(const Eigen::Vector3d &r,
                                  const double t) const
{
  const double arg = wavevector.dot(r) - freq * (t - delay);
  return (amplitude * 2 * field_orientation * gaussian(arg / width) * cos(arg));
}

不胜感激为什么会发生这种情况。

1 个答案:

答案 0 :(得分:1)

您需要使用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>