纳克级的奇不正常 [英] ng-class-odd not working properly

查看:88
本文介绍了纳克级的奇不正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我有这个控制器

  $ rootScope.nhCount = 0;angular.forEach(数据,功能(值,键){
      $ rootScope.nhCount = $ rootScope.nhCount + 1;
});

我的html尝试使用纳克级的奇纳克级,甚至像这样

 < UL纳克级的奇='时间线的倒'纳克级,甚至='时间线'>
            <李NG重复=nhCount在nhCount.data |排序依据:日期:真正的>

我使用的CSS发现这里

这应该放于右侧或屏幕左侧内容隔挡,按纳克级,甚至/ NG-类奇。这是行不通的。即使我移动纳克级的奇='时间线的倒'纳克级,甚至='时间表'中的 <李方式> 仍然没有工作。

我怎样才能使这项工作?我缺少的是在这里吗?

感谢


解决方案

使用$偶数和奇数$变量

\r
\r

VAR应用= angular.module(应用程序,[]);\r
\r
app.controller(MyCtrl功能($范围){\r
    \r
   $ scope.items = [1,2,3,4,5];\r
  \r
  });

\r

.timeline {\r
  背景色:黄色;\r
  颜色:红色;\r
  }\r
.timeline反转{\r
  背景颜色:绿色;\r
  颜色:红色;\r
  }

\r

&LT;脚本SRC =htt​​ps://ajax.googleapis.com/ajax /libs/angularjs/1.2.23/angular.min.js\"></script>\r
\r
&LT; D​​IV NG-应用=应用程序NG控制器=MyCtrl&GT;\r
    &LT;李NG重复=中的项项&GT;\r
     &LT;跨度纳克级={'时间表':$甚至,时间线的倒:$奇}&GT;\r
       {{项目}}\r
      &LT; / SPAN&GT;\r
    &LT; /李&GT;\r
  &LT; / DIV&GT;

\r

\r
\r

So, I have this controller

$rootScope.nhCount = 0;                

angular.forEach(data, function(value, key) {
      $rootScope.nhCount = $rootScope.nhCount + 1;
});

my html tries to use ng-class-odd and ng-class-even like so

<ul ng-class-odd="'timeline-inverted'" ng-class-even="'timeline'" >
            <li ng-repeat="nhCount in nhCount.data| orderBy:'date':true">

I use the css found here.

It supposed to put every other block of content in the right or left side of the screen, according to the ng-class-even / ng-class-odd. It is not working. Even if I move the ng-class-odd="'timeline-inverted'" ng-class-even="'timeline'" inside the <li> is still not working.

How I can make this work? What am I missing here?

Thanks

解决方案

use $even and $odd variable

var app = angular.module("app",[]);

app.controller("MyCtrl" , function($scope){
    
   $scope.items = [1,2,3,4,5];
  
  });

.timeline{
  background-color: yellow;
  color : red;
  }
.timeline-inverted{
  background-color: green;
  color : red;
  }

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<div ng-app="app" ng-controller="MyCtrl">
    <li ng-repeat="item in items">
     <span ng-class="{'timeline': $even, 'timeline-inverted': $odd}">
       {{item}}
      </span>
    </li>
  </div>

这篇关于纳克级的奇不正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆