Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在angularjs上应用jquery插件点重复分页_Jquery_Angularjs_Jquery Plugins - Fatal编程技术网

在angularjs上应用jquery插件点重复分页

在angularjs上应用jquery插件点重复分页,jquery,angularjs,jquery-plugins,Jquery,Angularjs,Jquery Plugins,我正在尝试设置一个指令来应用jquery插件。我的问题是,我希望它应用于ng repeat中带有分页集的项目列表。列表将随着每次单击下一页/上一页而改变。我甚至无法获得使用下面代码的初始页面 以下是我目前的代码: videoApp.directive('myEllip', function() { var linkFn = function(scope, element, attrs) { var synopsis = angular.element(element.children());

我正在尝试设置一个指令来应用jquery插件。我的问题是,我希望它应用于ng repeat中带有分页集的项目列表。列表将随着每次单击下一页/上一页而改变。我甚至无法获得使用下面代码的初始页面

以下是我目前的代码:

videoApp.directive('myEllip', function() {
var linkFn = function(scope, element, attrs) {
  var synopsis = angular.element(element.children());
    $(synopsis).dotdotdot({'watch':true});
};
return {
    restrict: 'A',
    link: linkFn
};
});


 <ul class="videos_all" my-ellip >
 <li ng-repeat="video in videos | filter:search | startFrom:currentPage*pageSize | limitTo:pageSize " class="videoSynopsis" >
      <p><a href ng-click="showVideo('{{video.VideoID}}')" >
      {{video.Title}}</a>
      <br><small class="muted">{{video.Description}}</small></p>        
</li>
</ul>
videoApp.directive('myEllip',function(){
var linkFn=函数(范围、元素、属性){
var synopsis=angular.element(element.children());
$(概要).dotdot({'watch':true});
};
返回{
限制:“A”,
链接:linkFn
};
});

  • {{video.Description}}

我得到了一份工作

dotdot:未找到“”的元素

在控制台中

感谢您的帮助。谢谢

语法错误

更改我的ellip> 到

编辑:


app.directive('dotdot',function(){
返回函数(范围、元素、属性){
$(元素).dotdot({'watch':true});
}
})

我遇到了类似的问题,但我对列表中的每个元素都有一个指令,当我调用
dotdotdot()
时,它将停止Angle将我的
{{title}
绑定到该值,因此我切换到了
ng bind=“title”
,它成功了。
我想在你的情况下,它可能看起来像:

videoApp.directive('myEllip', function() {
    var linkFn = function(scope, element, attrs) {
        element.dotdotdot({'watch':true});
    };
    return {
        restrict: 'A',
        link: linkFn
    };
});
和html

<ul class="videos_all">
  <li my-ellip ng-repeat="video in videos | filter:search | startFrom:currentPage*pageSize | limitTo:pageSize " class="videoSynopsis" >
    <p>
      <a href ng-click="showVideo('{{video.VideoID}}')" ng-bind="video.Title"></a>
      <br/>
      <small class="muted" ng-bind="video.Description"></small>
    </p>
  </li>
</ul>


我不确定
dotdotdot
如何处理子元素,因此您可能还需要在
a
small
上使用一些css才能使其工作(我假设您已经使用了)。

模板

<div dma-dotdotdot>{{movie.title}}</div>
(function () {
    'use strict';

    angular.module('dma.common').directive('dmaDotDotDot', [
        function dmaDotDotDot() {
            return {
                restrict: 'A',
                link: function (scope, element, attrs) {
                    scope.$evalAsync(function () {
                        element.dotdotdot({
                            wrap: 'letter'
                        });
                    });
                }
            };
        }
    ]);
}());
我测试了ng bind,但它似乎对我不起作用。ng bind隐藏内容,然后激发dotdot(),然后编译内容(这不起作用)

虽然这应该比scope更好的解决方案。$watch。我相信它比没有
$evalAsync()
的解决方案执行得更加一致


请参阅$rootScope.Scope#$evalAsync以了解有关何时触发的更多信息。

不是语法错误。我应该补充一点,我使用的是Angular 1.2 rc3。语法正确。Angular将属性的驼背符号更改为连字符。请查看:
(function () {
    'use strict';

    angular.module('dma.common').directive('dmaDotDotDot', [
        function dmaDotDotDot() {
            return {
                restrict: 'A',
                link: function (scope, element, attrs) {
                    scope.$evalAsync(function () {
                        element.dotdotdot({
                            wrap: 'letter'
                        });
                    });
                }
            };
        }
    ]);
}());