Angular UI bootstrap carousel获取活动幻灯片对象

时间:2017-02-11 17:45:53

标签: javascript angularjs angular-ui-bootstrap angular-ui

我正试图从active slide object获取slides array角色UI引导轮播: 我目前的解决方案:

app.controller('myContr', ['$scope', '$http', 'filterFilter',  function($scope, $http, filterFilter) {
            $scope.b = {};
            $scope.b.int = 5000;
            $scope.b.active = 0;

            var banners = [
                {
                    "delay": 5,
                    "position": "top",
                    "background": "img_url",
                },
                {
                    "delay": 5,
                    "position": "top",
                    "background": "img_url",
                }
            ];
            var b = $scope.b.banners = filterFilter(banners, {
                position: 'top'
            });
            $scope.$watch('b.active', function(active) {
                $scope.b.int = parseInt(b[active]['delay'])*1000;
            });

        }]);

HTML:

<body ng-controller="myContr">
    <div uib-carousel interval="b.int" active="b.active">
        <div uib-slide ng-repeat="ban in b.banners track by $index" index="$index">
            <img ng-src="{{ban.background}}" class="img-responsive center-block">
        </div>
    </div>
</body>

bootstrap UI允许设置幻灯片的active index,因此我使用$watch来确定活动幻灯片,但我在源代码中看到已经有$watch

我的问题是还有其他方法可以在不使用$watch的情况下获取活动幻灯片对象吗?

actual上有一个uib-slide参数,但找不到任何关于它的内容的文档。

0 个答案:

没有答案