Execute script/function on each iteration of ng-repeat

后端 未结 4 2136
温柔的废话
温柔的废话 2021-01-15 14:25

I am using ng-repeat on an element like this:

{{aS
4条回答
  •  余生分开走
    2021-01-15 15:03

    Here's an example of what I mean with using a directive.

    This directive:

    angular.module('directives', []).directive('alerter', function () {
        return {
            model: {
                size: '@'
            },
            link: function ($scope, element, attrs, controller) {
                alert(attrs.size)
            }
        };
    });
    

    Used like:

    alert 10
    alert 15
    

    Will execute.

提交回复
热议问题