ng-repeat
html和这段代码产生的行为有什么区别:
<div id="settings-row-{{key}}" class='settings-row' ng-repeat="(key, value) in items">
<div id='settings-source-{{key}}' class='settings-source settings-column'>{{key}}</div>
<div class='settings-slider settings-column'>
<input type="range" ng-model="items[key]" min="0" max="4" />
</div>
</div>
这个输入的代码:
<div id="settings-row-science" class='settings-row'>
<div id='settings-source-science' class='settings-source settings-column'>science</div>
<div class='settings-slider settings-column'>
<input type="range" ng-model="items['science']" min="0" max="4" />
</div>
</div>
<div id="settings-row-english" class='settings-row'>
<div id='settings-source-english' class='settings-source settings-column'>english</div>
<div class='settings-slider settings-column'>
<input type="range" ng-model="items['english']" min="0" max="4" />
</div>
</div>
<div id="settings-row-math" class='settings-row'>
<div id='settings-source-math' class='settings-source settings-column'>math</div>
<div class='settings-slider settings-column'>
<input type="range" ng-model="items['math']" min="0" max="4" />
</div>
</div>
我试图让第一个ng-repeat
代码与第二个键入的代码具有相同的行为,但由于某种原因,第一个代码的滑块会粘住并且不会平滑滑动。然而,第二个代码的滑块滑动顺畅。我没有考虑的差异是什么?任何建议,将不胜感激。
items
是:
{"science":0,"english":3,"math":4}