javascript - looping through a variable length with Angularjs templates? -


The car.images_length variable has a number, for example "4" . Therefore, depending on the peak, 4 & lt; Li & gt; I want to intersect and create elements

I know that car.images_length is the value because I have logged in using Javascript.

This is a very newbie question, but I'm new to Angulus.

Im trying to try, but I have no luck, this is my code:

HTML

  & lt; Ul rn-carousel-Corcelle-buffer class = "image" ng-ripat = "image in car.images_leng" & gt; & Lt; Li & gt; & Lt; IMG src = "picture / car / {{index}} .jpg" & gt; & Lt; / Li & gt; & Lt; / Ul & gt;    

You want to intersect at li elements, Code> UL

  and lt; ul rn-carousel rn-carousel-buffered class = "image" & gt; & Lt; li ng- repeat = "number in range (0, car. dimension_length)" & gt; & Lt; Img src = "picture / car / {{number}} .jpg" & gt; & Lt; / Li & gt; & Lt; / Ul & gt;   

ng-repeat does not assume an array value, then you have to create an array, in the above sample I did that from 0 to length

You must create a range function in your controller:

  $ scope.range = function (minimum, max) {var results = []; For (var i = min; i & lt; = max; i ++) results push (i); Return result; };   



Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

c# - passing input text from view to contoller with FacebookContext using Facebook app -

Calling a C++ function from C# by passing a string with variable size to it -