I have the following ionic html code.
<ion-nav-bar class="backarrow-bar" style="background-color:rgba(99,99,99,.5)">
<ion-nav-back-button class="button-clear">
<i class="ion-chevron-left" style="color:#ffffff;text-shadow: 2px 4px 3px rgba(0,0,0,0.3);"></i>
</ion-nav-back-button>
</ion-nav-bar>
And the following code is used to change the background-color of the ion-nav-bar
. However, the background color cannot be changed. I even put an inline style for background color for testing and it still doesn't work?
.directive('headerShrink', function ($document) {
return {
restrict: 'A',
link: function ($scope, $element, $attr) {
var header = $document[0].body.querySelector('.backarrow-bar');
var headerHeight = 44;
$element.bind('scroll', function (e) {
var scrollTop = e.target.scrollTop;
var alpha = Math.min(scrollTop / 44, 1);
// Not working
header.style.backgroundColor = 'rgba(99,99,99,' + alpha + ')';
// Not working either
// ionic.requestAnimationFrame(function () {
// header.style.backgroundColor = 'rgba(0,0,0,' + alpha + ')';
// });
});
}
}
})