with JS?
I'm doing this, but I think there is a better way
if (event.scrollTop >= 298) {
this.mySegment.nativeElement.className = 'segment segment-md ng-untouched ng-pristine ng-valid fixed';
} else {
this.mySegment.nativeElement.className = 'segment segment-md ng-untouched ng-pristine ng-valid'
}
SOLUTION: nativeElement has classList property, it is actually a set, so I can call .add any time I want and just add one item. if (event.scrollTop >= 298) { this.mySegment.nativeElement.classList.add('fixed'); } else { this.mySegment.nativeElement.classList.remove('fixed'); }
Обсуждают сегодня