Trying to incorporate Semantic UI into my Angular2 application has presented a challenge. I am unable to locate a router setting that allows me to change the default name of the "router-link-active" class to simply "active," which is crucial for proper menu display.
It seems that such a customization option does not currently exist, unlike in Vue.JS where it is available. Should I consider reaching out to developers to address this issue?
The workaround involves creating a custom directive that automatically adds the "active" class to all DOM elements with the "router-link-active" class, but I have encountered some obstacles along the way.
I came across a similar question, however, the suggested solution proved overly complex and ineffective in my case. After reviewing documentation, I devised an alternative approach as follows:
commons.ts:
@Directive({
selector: '.router-link-active',
host: {'[class.active]': 'trueConst'} //simply using 'true' may also suffice
})
export class ActiveRouterLinkClass {
trueConst: boolean = true; //if 'true' works, this line could be omitted
}
Subsequently, I imported ActiveRouterLinkClass into my main.component.ts and included it in the component's list of directives. However, this resulted in an error message stating: "EXCEPTION: Unexpected directive value 'undefined' on the View of component 'Main'". Any insights on what went wrong would be greatly appreciated!