我想为limitTo过滤器添加动态变量。
<div ng-repeat="test in tests">
{{(test.content | limitTo: strTestLimit[$index] || strTestLimit) + (test.content.length > strTestLimit ? '...' : '')}}
<span ng-if="test.content.length > strTestLimit && test.content.length != strTestLimit[$index]">
<button ng-click="showMore(test.content, $index)">Show more</button>
</span>
<span ng-if="test.content.length == strTestLimit[$index]">
<button ng-click="showLess($index)">Show less</button>
</span>
</div>
scope.strTestLimit = 100
scope.showMore = function(aa, index) {
scope['strTestLimit'+index] = aa.length
};
scope.showLess = function(index) {
scope['strTestLimit'+index] = 100;
};
我不知道如何在HTML中使用limitTo:strTestLimit + $ index。