angularjs bootstrap carousel无法正常工作

时间:2017-09-26 09:24:59

标签: jquery angularjs bootstrap-4

HTML

如何将活动课程添加到第一张图片? 我想从数据库中滑动图像,但我不能

<div id="myCarousel" class="carousel slide" data-ride="carousel">
  <div class="carousel-inner">
    <div ng-repeat="image in images">
      <div class="row" id="slider">
        <div class="col-md-6">
          <img src="../backend/uploads/{{image.images}}" width="350" height="370">
        </div>
        <div class="col-md-6 text-center" id="discount">
          <h3>Upto</h3>
          <h1>50<small>%</small></h1>
          <h3>Discount</h3>
        </div>
      </div>  <!-- row ending -->
    </div>
  </div>
    <a class="left carousel-control" href="#myCarousel" data-slide="prev">
      <span class="glyphicon glyphicon-chevron-left"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#myCarousel" data-slide="next">
      <span class="glyphicon glyphicon-chevron-right"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>

JS
这是我的JS代码,我从json获取数据

var fetch=angular.module("myApp",[])
fetch.controller('slideShowController', ['$scope', '$http', function ($scope, $http) {

$http({
    method: 'get',
    url: 'getdata.php'
    }).then(function successCallback(response) {
        $scope.images = response.data;
});

}]);

1 个答案:

答案 0 :(得分:0)

你没有任何循环可以循环image.images(名字暗示这是图像数组)。请阅读ngRepeat

ngRepeat中应该有可能获得当前元素的id。在此之后,如果索引为零(它是第一个元素),则可以使用if ngClass添加类active