gpt4 book ai didi

angularjs - Angular 轮播不起作用

转载 作者:行者123 更新时间:2023-12-03 08:03:00 24 4
gpt4 key购买 nike

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"
}

View (带中继器和不带中继器):

<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。

最佳答案

我试过下面的代码,它成功了。

<!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>

关于angularjs - Angular 轮播不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26731697/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com