【发布时间】:2017-02-06 17:01:09
【问题描述】:
你好,我有控制器模板,我在其中声明了两个用于横幅的指令。 所以我有 home.html 和
<div data-banner="{typeName: '1'}">
<div data-banner="{typeName: '2'}">
和
function bannerDirective() {
return {
restrict: 'A',
templateUrl: 'banner/banner.html',
controllerAs: 'vm',
bindToController: true,
controller: bannerController,
scope: {
bannerOptions: '=banner'
},
link: function(scope) {
scope.$watch('bannerOptions', function() {
$(".owl-carousel").owlCarousel({
loop: true,
autoWidth: true,
autoPlay: true,
pagination: false,
items: 1
});
});
}
};
}
我需要在这两个指令上使用$(".owl-carousel").owlCarousel 来显示路线更改两个横幅。而且我不知道如何使它工作。
【问题讨论】:
-
link传递一个元素。 -
在控制器中有从服务器获取横幅的方法。
-
也有可用的模块见github.com/jonahbron/angular-owl-carousel。在重新发明轮子之前检查模块
-
为此我讨厌 Angular,我不知道插件的存在,我浪费时间。谢谢,我想它会解决我的问题。
-
google 搜索不难
标签: javascript angularjs owl-carousel