ホームページ  >  記事  >  ウェブフロントエンド  >  Angularjs でカルーセル コマンド スワイパーを使用する方法のコード例を共有する

Angularjs でカルーセル コマンド スワイパーを使用する方法のコード例を共有する

黄舟
黄舟オリジナル
2017-05-31 10:21:062251ブラウズ

この記事は、Angularjsでのカルーセルコマンドスワイパーの使用に関する関連知識を主に紹介しています。非常に優れており、必要な友人は参考にすることができます

angualrjsのモバイル開発でカルーセルに遭遇しました。画像

インストール swiper  npm install --save swiper   或者 bower install --save swiper

ファイルパスの紹介

<link rel="stylesheet" href="../bower_components/swiper/dist/css/swiper.min.css" rel="external nofollow" />
<script src="../bower_components/swiper/dist/js/swiper.jquery.min.js"></script>

命令内の書き方

(function() {
 &#39;use strict&#39;;
 angular
  .module(&#39;campus.core&#39;) //对应项目的module 请换成自己的模块名称
  .directive(&#39;swipers&#39;,swipers);
  swipers.$inject = [&#39;$timeout&#39;];
  function swipers($timeout) {
   return {
    restrict: "EA",
    scope: {
     data:"="
    },
    template: &#39;<p class="swiper-container silder">&#39;+
        &#39;<ul class="swiper-wrapper">&#39;+
        &#39;<li class="swiper-slide" ng-repeat="item in data">&#39;+
        &#39;<a class="img40" href="{{item.contentUrl}}" rel="external nofollow" ><img ng-src="{{item.imgId}}" alt="" /></a>&#39;+
        &#39;</li>&#39;+
        &#39;</ul>&#39;+
        &#39;<p class="swiper-pagination"></p>&#39;+
        &#39;</p>&#39;,
    link: function(scope, element, attrs) {
       $timeout(function(){
         var swiper = new Swiper(&#39;.swiper-container&#39;, { //轮播图绑定样式名
          pagination: &#39;.swiper-pagination&#39;,  
          paginationClickable: true,    
          autoplay: 2500,
        }); 
       },100); 
    }
   };
  }
})();

データバインディングインターフェース返されたカルーセルリストvm.home.headImgsは返されたカルーセルチャートに対応します データリスト

りー

以上がAngularjs でカルーセル コマンド スワイパーを使用する方法のコード例を共有するの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。