angularJS: dotdotdot for overflow text and performance

后端 未结 4 896
暖寄归人
暖寄归人 2021-01-07 01:31

I\'m new to angularJS and maybe have written something bad...

but how could i right implement this plugin: https://github.com/BeSite/jQuery.dotdotdot

on my t

4条回答
  •  囚心锁ツ
    2021-01-07 01:50

    As @pankajparkar noted in comments, this really shouldn't be maintained in a $watch. Doing so executes the element.dotdotdot() configuration call several times in any given session--for example every time a key is pressed or the mouse is clicked. Part of the slowdown could be the plugin itself and how it manages the watching it does, but aside from that you should see improvement by simply removing the $watch:

    .directive('dotdotdot', function(){
        return {
            restrict: 'A',
            link: function(scope, element, attributes) {
                element.dotdotdot({watch: true, wrap: 'letter'});
            }
        }
    });
    

提交回复
热议问题