2016-12-05 1 views
0

Angular JS의 새로운 기능입니다. 나는 각도 js에서 caraousel에 일하고있다. DIV에 4의 SET가 있습니다.각도 번호가 정의 된 번호로 반복됩니다.

ng-if="$index % 4 == 0"을 사용한 후에 div가 생성되었지만 4 개의 항목을 가져올 수 없습니다.

반복적으로 4 개 항목을 가져 오는 데 INDEX를 어떻게 사용할 수 있습니까? DIV?

는 다음과 같은 코드에서 참조하시기 바랍니다 :

<div class="carousel-inner" ng-init="getSpecialDeals()"> 
    <div class="item" ng-class="{active: $index==0}" ng-repeat="specialDeals in SpecialDealsList" ng-if="$index % 4 == 0"> 
    <div class="row text-center"> 
     <!-- ITEM--> 
     <div class="span3"> 
     <div class="thumbnail product-item"> 
      <a href="#"> 
      <img ng-src="{{specialDeals.images}}"> 
      </a> 
     </div> 
     <h3> {{specialDeals.name}} </h3> 
     <p><a class="btn btn-large btn-block" href="http://www.bootstraptor.com">View details »</a> 
     </p> 
     </div> 
     <!-- ITEM--> 

     <!-- ITEM--> 
     <div class="span3"> 
     <div class="thumbnail product-item"> 
      <a href="#"> 
      <img src="https://s-media-cache-ak0.pinimg.com/564x/16/03/33/160333e0e9d6563729313131ff755964.jpg"> 
      </a> 
     </div> 
     <h3> {{specialDeals.name}}</h3> 
     <p><a class="btn btn-large btn-block" href="http://www.bootstraptor.com">View details »</a> 
     </p> 
     </div> 
     <!-- ITEM--> 
     <!-- ITEM--> 
     <div class="span3"> 
     <div class="thumbnail product-item"> 
      <a href="#"> 
      <img src="https://s-media-cache-ak0.pinimg.com/564x/16/03/33/160333e0e9d6563729313131ff755964.jpg"> 
      </a> 
     </div> 
     <h3>Product name</h3> 
     <p><a class="btn btn-large btn-block" href="http://www.bootstraptor.com">View details »</a> 
     </p> 
     </div> 
     <!-- ITEM--> 
     <!-- ITEM--> 
     <div class="span3"> 
     <div class="thumbnail product-item"> 
      <a href="#"> 
      <img src="https://s-media-cache-ak0.pinimg.com/564x/16/03/33/160333e0e9d6563729313131ff755964.jpg"> 
      </a> 
     </div> 
     <h3>Product name</h3> 
     <p><a class="btn btn-large btn-block" href="http://www.bootstraptor.com">View details »</a> 
     </p> 
     </div> 
     <!-- ITEM--> 

    </div> 
    </div> 

enter image description here

function _getSpecialDeals() { 
    if (document.getElementById('FCDivID')) { 
     $scope.requestData = $scope.requestData + '&category_id=' + $scope.featuredCategoryId; 
    } 

    $http(
     { 
      method : 'POST', 
      url : $scope.base + '/specialoffers/GetSpecialDeals', 
     crossDomain : true, 
     headers : { 
      'Content-Type' : 'application/x-www-form-urlencoded', 
      'key' : 'xxxxxxxxxxx' 
     }, 
     data : $scope.requestData, 
    }) 
    .then(
      function successCallback(response) { 
       document.getElementById("gifLoader").style.display = "none"; 
       //document.getElementById("gifLoader1").style.display = "none"; 

       document.getElementById("loader").style.display = "none"; 

       if(response.data.SpecialProductsList!=undefined){ 
        if(response.data.SpecialProductsList.length<5){ 
        $scope.flagArrow=false;} 
       } 
       if (response.data.status == "200") { 
        $scope.specialDeals = response.data; 
        $scope.totalPages = response.data.total_pages; 

        if ($scope.pageNumber > 1) { 
         for (var i = 0; i < response.data.SpecialProductsList.length; i++) { 
          $scope.SpecialDealsList 
            .push(response.data.SpecialProductsList[i]); 
         } 
        } else { 
         $scope.SpecialDealsList = $scope.specialDeals.SpecialProductsList; 
        } 
        if (document 
          .getElementById("list_item")) { 
         $scope.SpecialDealsList 
           .push({ 
            "product_id" : "1", 
            "name" : "Get All Deals", 
            "product_selling_price" : "0.00", 
            "wish_list" : "False", 
            "images" : "img/view-more.jpg", 
            "product_special_from_date" : "", 
            "product_special_to_date" : "", 
            "product_special_price" : "", 
           }) 
        }; 
       } 
       /*document.getElementById("wpf-loader-two").style.display = "none";*/ 
      }); 
    } 
} 
+3

R 대신 단일 '='

대신 기입 getSpecialDeals 함수()의 이렇게의 한 번 귀하의 게시물을 귀찮게하고 그것이 의미있는 확인하십시오? 컨트롤러는 어디 있습니까? ** getSpecialDeals() **는 의미합니까? ** SpecialDeals **는 의미합니까? – Aravind

답변

0

편집 : 그것은 .. 당신은이 구제품을 반복하는 NG-반복 사용 발견. 난 그냥 도움이 될하기 위해 몇 가지 실수를 지적하고 싶습니다, 내가 코드 실행을 할 수 없습니다 있지만이

<h3 ng-repeat="x in specialDeals">{{x.name}}</h3> 

도움이되기를 바랍니다, 그것은해야한다 : -

if(response.data.SpecialProductsList!==undefined){ 

$scope.getSpecialDeals=function() { if (document.getElementById('FCDivID'))..... 
관련 문제