我使用ng-include时轮播滑块断开

时间:2015-11-03 08:01:05

标签: javascript angularjs

在我的主页面中,我包含轮播文件,

<div data-ng-include="'views/header/template/home_slider.html'"></div>

和home_slider.html包含以下代码,

<section class="carousel-wrapper" interval="myInterval.value" ng-if="isHome" ng-controller="slideCtrl">
        <div id="carousel-big">
            <div class="item" style="background-image:url(assets/img/slide1.jpg);">
                <div class="caption">

                    <h1>This is where title<br> goes, short or long</h1>
                    <p>by UserX</p>
                    <span>1000 views | 3 weeks ago</span>
                    <button class="btn btn-primary">watch now</button>
                </div>
            </div>
            <div class="item" style="background-image:url(assets/img/slide2.jpg);">
                <div class="caption">
                    <h1>This is where title<br> goes, short or long</h1>
                    <p>by UserX</p>
                    <span>1000 views | 3 weeks ago</span>
                    <button class="btn btn-primary">watch now</button>
                </div>
            </div>
            <div class="item" style="background-image:url(assets/img/slide1.jpg);">
                <div class="caption">
                    <h1>This is where title<br> goes, short or long</h1>
                    <p>by UserX</p>
                    <span>1000 views | 3 weeks ago</span>
                    <button class="btn btn-primary">watch now</button>
                </div>
            </div>
            <div class="item" style="background-image:url(assets/img/slide2.jpg);">
                <div class="caption">
                    <h1>This is where title<br> goes, short or long</h1>
                    <p>by UserX</p>
                    <span>1000 views | 3 weeks ago</span>
                    <button class="btn btn-primary">watch now</button>
                </div>
            </div>
            <div class="item" style="background-image:url(assets/img/slide1.jpg);">
                <div class="caption">
                    <h1>This is where title<br> goes, short or long</h1>
                    <p>by UserX</p>
                    <span>1000 views | 3 weeks ago</span>
                    <button class="btn btn-primary">watch now</button>
                </div>
            </div>
            <div class="item" style="background-image:url(assets/img/slide2.jpg);">
                <div class="caption">
                    <h1>This is where title<br> goes, short or long</h1>
                    <p>by UserX</p>
                    <span>1000 views | 3 weeks ago</span>
                    <button class="btn btn-primary">watch now</button>
                </div>
            </div>
        </div>
    </section>

使用ng-include添加单独的页面后,我的轮播无法正常工作,页面完全崩溃但如果我将这些代码包含在我的主页面中,那么它的工作正常。我怎么解决呢?

1 个答案:

答案 0 :(得分:0)

你必须在ng-include之后写src:

<强> REPLACE:

<div data-ng-include="'views/header/template/home_slider.html'"></div>

。通过

<div ng-include src="'views/header/template/home_slider.html'"></div>

这将解决问题。 SOURCE