我在angularjs和jquery滑块函数中使用指令 我在onload上包含滑块功能很好。在我更新我的数组滑块图像后,不调用jquery只显示图像..
指令代码:
sampleApp.directive("imagedata", function ($compile) {
return {
restrict: "E",
link: function (scope, element, attrs) {
scope.$watch(attrs.value, function(newValue) {
element.html("<img src=./img/"+newValue.name+">");
$(".owl-demo").owlCarousel({
autoPlay: 3000,
items : 6,
itemsDesktop : [1199,3],
itemsDesktopSmall : [979,3],
itemsTablet: [900,3], //2 items between 600 and 0
itemsMobile :[1800,6]
});
$compile(element.contents())(scope);
});
}
};
});
index.html页面:
<script>
$(document).ready(function() {
$(".owl-demo").owlCarousel({
autoPlay: 3000,
items : 6,
itemsDesktop : [1199,3],
itemsDesktopSmall : [979,3],
itemsTablet: [900,3], //2 items between 600 and 0
itemsMobile :[1800,6]
});
});
</script>
<div class="col-md-9" ng-controller="AddOrderController">
<button ng-click="demo()">Update</button>
<div class="owl-demo" class="owl-carousel" ng-repeat="a in datas">
<div class="item" ng-repeat="d in a.item track by $index">
<imagedata value="d"></imagedata>
</div>
</div>
</div>
onload滑块功能正常。我正在做新的滑块图像upate使用范围观看图像显示cound not调用滑块功能..