Warning: The magic method Math_Captcha::__wakeup() must have public visibility in /usr/www/users/seowme/siekiera-online.de/wp-content/plugins/wp-math-captcha/wp-math-captcha.php on line 87

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/seowme/siekiera-online.de/wp-content/plugins/wp-math-captcha/wp-math-captcha.php:87) in /usr/www/users/seowme/siekiera-online.de/wp-content/plugins/wp-math-captcha/includes/class-cookie-session.php on line 46

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/seowme/siekiera-online.de/wp-content/plugins/wp-math-captcha/wp-math-captcha.php:87) in /usr/www/users/seowme/siekiera-online.de/wp-content/plugins/wp-math-captcha/includes/class-cookie-session.php on line 49

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/seowme/siekiera-online.de/wp-content/plugins/wp-math-captcha/wp-math-captcha.php:87) in /usr/www/users/seowme/siekiera-online.de/wp-content/plugins/wp-math-captcha/includes/class-cookie-session.php on line 49

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/seowme/siekiera-online.de/wp-content/plugins/wp-math-captcha/wp-math-captcha.php:87) in /usr/www/users/seowme/siekiera-online.de/wp-content/plugins/wp-math-captcha/includes/class-cookie-session.php on line 49

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/seowme/siekiera-online.de/wp-content/plugins/wp-math-captcha/wp-math-captcha.php:87) in /usr/www/users/seowme/siekiera-online.de/wp-content/plugins/wp-math-captcha/includes/class-cookie-session.php on line 49

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/seowme/siekiera-online.de/wp-content/plugins/wp-math-captcha/wp-math-captcha.php:87) in /usr/www/users/seowme/siekiera-online.de/wp-content/plugins/wp-math-captcha/includes/class-cookie-session.php on line 49
Angular JS 1.x [ngRepeat] mittels Integer – vom entwickler für entwickler

Angular JS 1.x [ngRepeat] mittels Integer

Oft genug kommt es vor das man eine kleine Schleife braucht um eine gewisse Anzahl an Einträgen zu erzeugen.

In etwa so:

<ul>
   <li><span>1</span></li>
   <li><span>2</span></li>
   <li><span>3</span></li>
   <li><span>4</span></li>
   <li><span>5</span></li>
</ul>

Der einfachste Weg geht über eine kleine Funktion im controller.

$scope.number = 5;
$scope.getNumber = function(num) {
    return new Array(num);   
}

In der Template Datei kann das dann so aufgerufen werden:

<ul>
    <li ng-repeat="i in getNumber(number)"><span>{{$index+1}}</span></li>
</ul>

Seit der Version 1.6 muss ein Index mit angegeben werden. Dann sieht das so aus:

<ul>
    <li ng-repeat="i in getNumber(number) track by $index"><span>{{$index+1}}</span></li>
</ul>

 

Scroll to Top