My Angular button keeps re-rendering repeatedly, I think its linked to the way I handle the application of my [ngClass], as per the comment in Multiple conditions in ngClass - Angular 4.
HTML
<button
[ngClass]="getCourseContentButtonClass(button.uid, button.title)"
></button>
Component
isCourseContentButtonPrimary(title: string) {
return CourseContentService.IsCourseContentButtonPrimary(title);
}
isCourseContentElementSelected(uid: string) {
return this.selectedCourseElementUid === uid;
}
getCourseContentButtonClass(uid: string, title: string) {
let courseContentButton;
if (CourseContentService.IsCourseContentButtonPrimary(title)) {
courseContentButton = 'btn btn-sm btn-primary mr-3 course-content-button ';
} else {
courseContentButton = 'btn btn-sm btn-primary-soft mr-3 course-content-button ';
}
if (this.isCourseContentElementSelected(uid)) {
courseContentButton += ' course-content-button-active';
}
return courseContentButton;
}