3

bower.json 文件的内容:

{
  "name": "blue",
  "version": "0.0.0",
  "dependencies": {
    "angular": "1.3.1",
    "json3": "~3.3.1",
    "es5-shim": "~3.1.0",
    "bootstrap-sass-official": "~3.2.0",
    "angular-sanitize": "1.3.1",
    "angular-animate": "1.3.1",
    "angular-touch": "1.3.1",
    "restangular": "~1.4.0",
    "ui-bootstrap": "~0.11.2",
    "ui-router": "~0.2.11",
    "ng-grid": "~2.0.13",
    "angular-bootstrap": "~0.11.2",
    "angular-carousel": "~0.3.5"
  },
  "devDependencies": {
    "angular-mocks": "1.3.1",
    "angular-scenario": "1.3.1"
  },
  "appPath": "app"
}

查看(带中继器和不带中继器):

<div class="attachments col-lg-12">
    <ul rn-carousel class="image">
        <li ng-repeat="image in email.value.files">
            <div class="layer">{{ image }}</div>
        </li>
    </ul>
    <ul rn-carousel class="image">
        <li>slide #1</li>
        <li>slide #2</li>
        <li>slide #3</li>
    </ul>
</div>

email.value.files

["http://localhost:1337/files/105/Protein_5.png","http://localhost:1337/files/105/Protein_4.png","http://localhost:1337/files/105/Protein_3.png","http://localhost:1337/files/105/Protein_2.png"]

控制台没有错误,存在 css 文件,使用检查元素时指令的根元素为 0px-0px。

4

1 回答 1

-1

我尝试了下面的代码并且它有效。

<!DOCTYPE html>
<html ng-app>
<head>
    <title>ng Crousal</title>
   <style type="text/css">
        #slides_control > div{
        height: 200px;
    }
    img{
        margin:auto;
        width: 400px;
    }
    #slides_control {
        position:absolute;
        width: 400px;
        left:50%;
        top:20px;
       margin-left:-200px;
    }
  </style>
</head>
<body>
<div ng-app="app">
  <div ng-controller="CarouselDemoCtrl" id="slides_control">
    <div>
      <carousel interval="myInterval">
        <slide ng-repeat="slide in slides" active="slide.active">
          <img ng-src="{{slide.image}}">
          <div class="carousel-caption">
            <h4>Slide {{$index+1}} : #</h4>
          </div>
        </slide>
      </carousel>
    </div>
  </div>
</div>  
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.10.0/ui-bootstrap-tpls.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<script>
        angular.module('app', ['ui.bootstrap']);
        function CarouselDemoCtrl($scope) {
            $scope.myInterval = 3000;
            $scope.slides = [
            {
                image: 'http://lorempixel.com/400/200/'
            },
            {
                image: 'http://lorempixel.com/400/200/food'
            },
            {
                image: 'http://lorempixel.com/400/200/sports'
            },
            {
                image: 'http://lorempixel.com/400/200/people'
            }
             
          ];
        }
     
</script>
</body>
</html>

于 2014-11-19T21:15:41.970 回答