我使用AngularJS和JQuery Cycle插件构建了这个网站。一切都很好,直到我需要将我的html partials移动到单独的文件夹中。现在当我运行代码时,我发现jQuery Cycle插件停止工作了。在Google上搜索后,我发现我需要创建一个指令来保留jQuery Cycle功能,但我不知道如何创建这样的指令,使得我在Angular网站中能够使用jQuery Cycle插件。
下面是jQuery代码和工作状态:
下面是jQuery代码和工作状态:
$(".items").cycle({
fx: 'scrollHorz',
speed: 'slow',
timeout: 1000,
next: '.move-left',
prev: '.move-right'
});
这个例子是一个不可用的指令方法。
myAngularApp.directive('cycle', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
$(".items").cycle({
fx: 'scrollHorz',
speed: 'slow',
timeout: 1000,
prev: '.move-left',
next: '.move-right'
});
}
};
});
有人能告诉我如何创建一个指令,让Cycle插件在Angular网站中工作吗?