【发布时间】:2015-10-22 10:00:42
【问题描述】:
我正在使用 ng-route 和 ng-animate 开发 AngularJS SPA。我正在尝试使用 ng-show 在index.html#/ 上显示引导轮播。非常简单的任务。
我希望轮播显示在索引页面上,而不是在关于页面或联系页面上。
我正在尝试在我的indexController 中执行逻辑,如下所示:
if ($location.path() == "/") {
$scope.isIndexPage = true;
}
在我的 HTML 中:
<div id="myCarousel" class="carousel slide" data-ride="carousel" ng-show="isIndexPage">
但它没有按预期工作:轮播不显示。删除 ng-show 属性后,轮播会显示,但会显示在所有页面上。
如何让轮播仅显示在索引页面上?我尝试过诸如ng-include-ing 和ng-ifing carousel.htm 之类的变体。许多 Google 搜索(例如“AngularJS SPA 和 Bootstrap Carousel”)揭示了未回答的 SO 问题。
提前感谢您的任何意见。这是PLUNKER。
【问题讨论】:
标签: angularjs twitter-bootstrap carousel ngroute