angular-vs-repeat icon indicating copy to clipboard operation
angular-vs-repeat copied to clipboard

[Question] - How to use variable size in the most recent version

Open angel1st opened this issue 6 years ago • 4 comments

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!

angel1st avatar Sep 13 '18 05:09 angel1st

@kamilkp would be great if you could provide an example of how this works. @angel1st any luck figuring this one out?

squidsoup avatar Feb 12 '19 07:02 squidsoup

@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 avatar Jun 03 '19 13:06 duall

@duall afraid not sorry.

squidsoup avatar Jun 03 '19 21:06 squidsoup

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

shazzygh avatar May 08 '21 11:05 shazzygh