Angularjs repeat do every 2nd time

Angularjs repeat do every 2nd time

So I wanted to do something in AngularJS for every 2nd item in my ng-repeat. I’m using Bootstrap’s rows and columns so I wanted to get some padding in between them without using an offset.

angularjs repeat do every 2nd time

I’m just using col-md-6 which splits the row into 2 columns at 50%. So I need to add a class for each item on the li so it knows if it’s first or second item basically.

So then I found Angular provides such a directive already! It’s called ngClassOdd. So I added thes attributes to my list items and hey presto!

If we inspect it, we can see it’s adding the correct class to our DOM elements.

If we inspect it, we can see it's adding the correct class to our DOM elements.

And with the styles (I’m using LESS) I get my gap!

finished result angularjs

Conclusion:

So these are the Angularjs repeat do every 2nd time .If you like this tutorial script then share it with your community. If you have any suggestion Feel free to comment below.If you want to learn more about PHP, CodeIgniterAngularJSLaraveljQuery  Web Development then daily visit PHPCodify. Sharing is Caring.

 Angularjs repeat do every 2nd time

Read previous post:
3+ Premium AngularJS CRUD Tables and Directives

3+ Premium AngularJS CRUD Tables and Directives Following on from the Top 10 AngularJS Table Demos post I did a...

Close