0

我正在使用 dotdotdot 似乎是一个很酷的插件......但是,我需要使用它的角度,如果加载了新元素(通过 http.get <> ng-repeat)则不起作用......

所以我发现有一个angular-dotdot ...如何使用它?不是很清楚...

假设我有 dotdotdot 的经典用法,如下所示:

// ellipsis body to 4 lines height
var ellipsis = $(".ellipsis-case-body");
var nrLines = 4;
var ellHeight = parseInt(ellipsis.css('line-height'), 10) * nrLines;
ellipsis.dotdotdot({ height: ellHeight });

// ellipsis title to 1 line height
ellipsis = $(".ellipsis-case-title");
nrLines = 1;
ellHeight = parseInt(ellipsis.css('line-height'), 10) * nrLines;
ellipsis.dotdotdot({ height: ellHeight });

如何与角度一起使用它?

在他们的文档中

$scope.myText = 'some really long text';

模板:

<p dotdotdot='myText'>{{myText}}</p>

但是如何设置选项?

4

1 回答 1

0

看起来你不能。这是指令源代码,来自 GitHub:

angular.module('dotdotdot-angular', [])
    .directive('dotdotdot', ['$timeout', function($timeout) {
        return {
            restrict: 'A',
            link: function(scope, element, attributes) {

                // We must pass in the scope binding, e.g. dotdotdot='myText' for scope.myText
                scope.$watch(attributes.dotdotdot, function() {

                    // Wait for DOM to render
                    // NB. Don't use { watch: true } option in dotdotdot as it needlessly polls
                    $timeout(function() {
                        element.dotdotdot();
                    }, 400);
                });
            }
        }
}]);

请注意,没有任何内容传递给.dotdotdot().

你可能想分叉这个或者只是写你自己的。

于 2015-12-17T18:44:01.820 回答