ngRepeat中的静态列表项

Ray*_*oen 1 angularjs angularjs-directive angularjs-ng-repeat

所以,

我使用ngRepeat渲染基本列表,但首先<li>需要静态内容,而不是从数据数组生成:

例如

<ul ng-repeat="item in items">
  <li>This is text from the template and will always be the same.</li>
  <li>{{item}}</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

我也看过使用ng-repeat-start,但是不能完全找到解决方案.

cha*_*tfl 7

人们想要ng-repeat在父元素上使用它是一种常见的误解,实际上你在实际重复的元素上使用它.

您只需将其更改为:

<ul>
  <li>This is text from the template and will always be the same.</li>
  <li  ng-repeat="item in items">{{item}}</li>
</ul>
Run Code Online (Sandbox Code Playgroud)