Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
angel1st opened this issue Sep 13, 2018 · 4 comments
Open

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

angel1st opened this issue Sep 13, 2018 · 4 comments

Comments

@angel1st
Copy link

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!

@squidsoup
Copy link

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

@duall
Copy link

duall commented Jun 3, 2019

@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...

@squidsoup
Copy link

@duall afraid not sorry.

@shazzygh
Copy link

shazzygh commented May 8, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants