M Arfan
M Arfan

Reputation: 4575

Angular JS ng-class or ng-if use

How I do following Code in angular JS

// PHP Code 
<?php foreach($data as $key=>$row) { 
 if($key%2 == 0) { ?>
    <div class="col 3"> Run this 
    <ul>
<?php } ?>
    <li> Some Data </li>

  <?php if($key%2 == 1) { ?>
    </ul></div>
   <?php } } ?>

I want to run above code in angular JS. any help appreciated.

Upvotes: 0

Views: 61

Answers (1)

Wasiq Muhammad
Wasiq Muhammad

Reputation: 3118

Like this

<div ng-repeat="key in data">
<div ng-if="(key%2 == 0)" class="col 3"> Run this 
    <ul>
    <li> Some Data </li>
    </ul>
</div>

<div ng-if="(key%2 == 1)"> Run this 
    <ul>
    <li> Some Data </li>
    </ul>
</div>

</div>

Upvotes: 1

Related Questions