We encounter the function of carousel graphs in angualrjs mobile development
Installswiper npm install --save swiper
orbower install --save swiper
Introduce file path
<link rel="stylesheet" href="../bower_components/swiper/dist/css/" rel="external nofollow" /> <script src="../bower_components/swiper/dist/js/"></script>
How to write in directives
(function() { 'use strict'; angular .module('') //Replace the module of the corresponding project with your own module name .directive('swipers',swipers); swipers.$inject = ['$timeout']; function swipers($timeout) { return { restrict: "EA", scope: { data:"=" }, template: '<div class="swiper-container silder">'+ '<ul class="swiper-wrapper">'+ '<li class="swiper-slide" ng-repeat="item in data">'+ '<a class="img40" href="{{}}" rel="external nofollow" ><img ng-src="{{}}" alt="" /></a>'+ '</li>'+ '</ul>'+ '<div class="swiper-pagination"></div>'+ '</div>', link: function(scope, element, attrs) { $timeout(function(){ var swiper = new Swiper('.swiper-container', { //The carousel image binding style name pagination: '.swiper-pagination', paginationClickable: true, autoplay: 2500, }); },100); } }; } })();
data The carousel list returned by the binding interface The data list returned by the corresponding carousel chart
<!--Carousel--> <swipers data="" ></swipers>
The above is the use of carousel image command swiper in Angularjs introduced to you by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message. The editor will reply to everyone in time!