Angular JS ng-class或ng-if use

时间:2016-03-25 10:30:49

标签: php angularjs ng-class

我如何在角度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 } } ?>

我想在angular JS中运行上面的代码。任何帮助表示感谢。

1 个答案:

答案 0 :(得分:1)

喜欢这个

<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>