javascript – angularJS:dotdotdot用于溢出文本和性能
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了javascript – angularJS:dotdotdot用于溢出文本和性能,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2324字,纯文字阅读大概需要4分钟。
内容图文
我是angularJS的新手,也许写了一些不好的东西……
但是我怎么能正确实现这个插件:https://github.com/BeSite/jQuery.dotdotdot
在我的桌子上?
现在用我的代码我的编辑表格和表格真的不太快……真的太慢了??……我做错了什么?
指示:
.directive('dotdotdot', function(){
return {
restrict: 'A',
link: function(scope, element, attributes) {
scope.$watch(function() {
element.dotdotdot({watch: true, wrap: 'letter'});
});
}
}
});
和表:
<table id="articles" class="table table-striped articles-table">
<thead>
<tr class="table-row">
<th data-ng-click="predicate = 'Date'; reverse=!reverse">Date<i ng-class="{'arrow-down' : (reverse && predicate==='Date') || (predicate!=='Date'), 'arrow-up' : !reverse && predicate==='Date'}"></i></th>
<th data-ng-click="predicate = 'Title'; reverse=!reverse">Title<i ng-class="{'arrow-down' : (reverse && predicate==='Title') || (predicate!=='Title'), 'arrow-up' : !reverse && predicate==='Title'}"></i></th>
<th data-sorter="false">article</th>
<th data-sorter="false"></th>
<th data-sorter="false"></th>
</tr>
</thead>
<tbody>
<tr data-ng-repeat="article in articles | orderBy:predicate:reverse" data-id="{{article.Id}}" class="table-row">
<td class="text-nowrap">
<div class="articles-cell">
{{article.Date}}
</div>
</td>
<td>
<div class="articles-cell article-text-area" dotdotdot>
{{article.Title}}
</div>
</td>
<td>
<div class="articles-cell">
<a href="javascript:void(0)" data-ng-click="showarticle(article)" data-toggle="modal" data-target="#new-article" class="action">
<img data-ng-src="{{article.Photo}}" data-err-src="images/no_photo.png" class="article-img img-rounded img-responsive" alt="article" />
</a>
</div>
</td>
<td>
<div class="articles-cell" dotdotdot>
<div class="content" data-ng-bind-html="article.Content" class="articles-row" ></div>
</div>
</td>
<td class="crud-arr">
</td>
</tr>
</tbody>
</table>
即使我通过绑定重写它 – 它会慢…
我做错了什么?
解决方法:
正如@pankajparkar在评论中指出的那样,这真的不应该保留在$watch中.这样做会在任何给定的会话中多次执行element.dotdotdot()配置调用 – 例如,每次按下一个键或单击鼠标时.减速的一部分可能是插件本身以及它如何管理它的观察,但除此之外,您应该通过简单地删除$watch来看到改进:
.directive('dotdotdot', function(){
return {
restrict: 'A',
link: function(scope, element, attributes) {
element.dotdotdot({watch: true, wrap: 'letter'});
}
}
});
内容总结
以上是互联网集市为您收集整理的javascript – angularJS:dotdotdot用于溢出文本和性能全部内容,希望文章能够帮你解决javascript – angularJS:dotdotdot用于溢出文本和性能所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。