zoukankan      html  css  js  c++  java
  • AngularJs学习之ng-repeat

      ng-repeat用来遍历一个集合或为集合中的每个元素生成一个模板实例。集合中的每个元素都会被赋予自己的模板和作用域。同时每个模板实例的作用域中都会暴露一些特殊的属性。

      $index:遍历的进度(0 ... length-1)

      $first:当元素是遍历的第一个时值为true

      $middle:当元素处于第一个和最后元素之间时为true。

      $last:当元素是遍历的最后一个时值为true。

      $even:当$index值为偶数时值为true。

      $odd:当$index值为奇数时值为true。

      使用Directive

    <div ng-controller="ImageController">
        <div ng-repeat="image in images" image-repeat-directive>
            <img ng-src="{{image.src}}" />
        </div>
    </div>
    angular.module('ImageApp', [])
    .directive('imageRepeatDirective', function () {
        return function (scope, element, attrs) {
            //angular.element(element);
            if (scope.$last) {
                alert("I am the last!");
            }
        };
    });
  • 相关阅读:
    Python操作SQLServer示例
    T-SQL 谓词和运算符
    T-SQL 语句—— 游标
    SQL中的循环、for循环、游标
    web自动化快速入门
    接口自动化的总结
    jenkins知识
    SVN知识
    random.sample函数
    项目实战(六)
  • 原文地址:https://www.cnblogs.com/rubekid/p/4821136.html
Copyright © 2011-2022 走看看