Answers for "add trackby index conditionally in angularjs"

3

ngfor index

/*
ngFor with index in angular is used here for generating 'li' element till the studentDetails array length.
And also make a note if you are using angular 1 then you have to replace 'let' with '#', but its ok if you are using angular 2 or above.
*/

<ul>
    <li *ngFor="let student of studentDetails; index as i;" [attr.data-index]="i">
        {{student}}
    </li>
</ul>

/*
I hope it will help you.
Namaste
*/
Posted by: Guest on May-07-2020
-2

angular for loop

let array = [1,2,3];
for (let i = 0; i < array.length; i++) {
  console.log(array[i]);
}
Posted by: Guest on March-05-2020

Code answers related to "add trackby index conditionally in angularjs"

Browse Popular Code Answers by Language