我需要在我的应用中为单个 View 添加全屏 CSS 背景。我试图通过向 body
添加一个类来实现这一点然而,这仍保留在缓存中,并在切换 View 时保留在正文中。
我遇到这个问题是因为我的 <div ng-view=""></div>
在 <body>
内所以我不能轻易地从 View 中添加全屏 BG。
最佳答案
为了快速简单地回答,这就是我所做的。
将条件类应用到 ng-view
index.html
ng-class="{'homebg' : home}"
样式.scss
.homebg {
高度:100%;
背景图像:url('../images/home-bg.jpg');
背景尺寸:封面;
背景位置:中心中心;
}
Controller.js
$scope.home = true;
关于javascript - 将整页背景添加到 Angular JS 中的单个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33202625/