0

目前在 AngularJS 中存在 JSON 问题,我在其中选择了“img”对象,它控制日志,但不适用于范围。任何人都可以解释一下吗?

'use strict';

angular.module('AppliedSiteApp').controller('CarouselCtrl', function ($scope) {

    // CAROUSEL IMAGES
    var carouselImages = [
        {
            "img": "background-image: url('images/carousel/carousel1.jpg')"
        },
        {
            "img": "'background-image': 'url(images/carousel/carousel2.jpg)'"
        },
        {
            "img": "'background-image': 'url(images/carousel/carousel3.jpg)'"
        },
        {
            "img": "'background-image': 'url(images/carousel/carousel4.jpg)'"
        },
        {
            "img": "'background-image': 'url(images/carousel/carousel5.jpg)'"
        },
        {
            "img": "'background-image': 'url(images/carousel/carousel6.jpg)'"
        },
        {
            "img": "'background-image': 'url(images/carousel/carousel7.jpg)'"
        },
        {
            "img": "'background-image': 'url(images/carousel/carousel8.jpg)'"
        }
    ];

    // SET INITIAL CAROUSEL IMAGE
    $scope.carouselImage = carouselImages[0].img;

    console.log('image', $scope.carouselImage);

});

我正在尝试将其应用于范围:

<div class="carousel" ng-style="carouselImage"></div>
4

1 回答 1

-2

您可以使用 angular-carousel 。看到这个

角度旋转木马

于 2013-09-18T10:23:22.087 回答