1
我正在使用angular js和data-ng-repeat來獲取數據。 以下是我的HTML。
<div id="newsslide" class="owl-carousel owl-theme">
<div class="item darkCyan" data-ng-repeat="items in NewsList">
Hello
</div>
</div>
這裏是我的JS
$scope.getNewsList = function (Id) {
var getData = HomeService.getNewsList(Id);
getData.then(function (_result) {
$scope.getMediaList(Id);
if (_result.data.length > 0) {
$scope.NewsList = _result.data;
$scope.NewsNoRecords = false;
$timeout(function() {
$("#newsslide").owlCarousel({
items: 3,
nav: false,
dots: true,
rtl:true,
// autoPlay: 3000,
navText: [
"<i class='fa fa-angle-left'></i>",
"<i class='fa fa-angle-right'></i>"
]
});
}, 1000);
}
else {
$scope.NewsNoRecords = true;
}
}, function (errorMsg) {
$scope.loadingDataEntryList = false;
console.log('Error in getting records - ' + JSON.stringify(errorMsg))
});
}
數據結合精細。但它顯示
TypeError: $(...).owlCarousel is not a function.
我也嘗試通過粘貼在Chrome開發者控制檯中運行$("#newsslide").owlCarousel({});
。我得到錯誤
Uncaught TypeError: $(...).owlCarousel is not a function at Anonymous:1:18.
下面是我添加的庫序列,[jQuery庫在此圖像之前的頭標記中。這就是爲什麼它造成問題] [] 1
我已經搜索了很多。請幫忙。謝謝
檢查您是否在應用程序初始化模塊中添加了參考庫,並且它也出現在頁面中(通過查看頁面源) –
顯示加載到您的主HTML文件中的'
使用所有庫附近和以上的jquery解決了這個問題。在此之前,jquery已成爲頭條。謝謝...
來源
2017-07-04 09:34:22 sid1001