0

私は dotdotdot を使用していますが、クールなプラグインのようです...

だから私はangular-dotdotdotがあることを発見しました...それを使用する方法? あまり明確ではありません...

次のような 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 });

angularでそれを使用する方法は?

彼らのドキュメントでは

$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 に答える