angular-vs-repeat
angular-vs-repeat copied to clipboard
[Question] - How to use variable size in the most recent version
Hi there, I have a simple question re this directive usage: Looking at the examples, I can see the one I am interested in - variable heights. However, the example sources are three years old and do not reflect the most recent directive version. Here comes my question - How can I use variable height with the most recent directive?
In the example, I can see the code snippet:
<div class="repeater-container" data-vs-repeat="100" vs-size-property="size">
<div class="item-element well" ng-repeat="item in items.collection" ng-style="{height: item.size + 'px'}" ng-click="item.size = item.size + 30; $emit('vsRepeatTrigger')">
<span>{{item.text}}</span>
</div>
</div>
and it is clear that ng-style
is used to set each item's height.
In the most recent version, however you have following snippet:
<div vs-repeat="{size: 50}"> <!-- the specified element height is 50px -->
<div ng-repeat="item in someArray">
<!-- content -->
</div>
</div>
and later is told, quote:
size - an angular expression evaluating to the element's size (in pixels) - it is possible to use the ngRepeat's local repeating variable in this expression
so, my understanding is I should be able to use something like <div vs-repeat="{size: item.size}">
, however, as long as size
variable is outside the ngRepeat
scope, I don't see how this might happen.
Any hints / code snippet would be really appreciated, thanks!
@kamilkp would be great if you could provide an example of how this works. @angel1st any luck figuring this one out?
@squidsoup @kamilkp Have you guys figured this out? Just for this feature I have to use older version 1.x I need to access item or at least $index to calculate item size...
@duall afraid not sorry.
A couple of years later... Fellas, I figured it out through trial and error! You need to declare item.size
as a string 'item.size'
like so:
<div vs-repeat="{size: 'item.size'}">
<div ng-repeat="item in someArray">
<!-- content -->
</div>
</div>
This should really be documented somewhere