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!");
            }
        };
    });
  • 相关阅读:
    react-路由简单封装
    promise 和 async / await
    数据结构 栈 、 队列 、 链表
    ES6 Symbol
    react-react常用包与对应使用
    node-egg的使用
    自我理解与概述-BFC(Block formatting context)
    Git
    MySQL优化技巧
    Shiro
  • 原文地址:https://www.cnblogs.com/rubekid/p/4821136.html
Copyright © 2011-2022 走看看