I am facing an issue with my Angular 1.5 component and controller that uses the controllerAs syntax. I have written a function to add an extra css class to the component element if a specific html element exists on the page. However, when switching to a different state where this html element does not exist, the additional css class remains applied to the component. The only way to reset this functionality is by refreshing the app. This component is utilized on every page throughout the application.
Here is an example of the component:
function myComponentController() {
activate();
function activate(){
addAdditionalCssClass();
}
function addAdditionalCssClass(){
// code for adding additional css class to the component
// if html element exists
}
}
While everything works as expected on pages with the required html element, the problem arises when navigating to a state where the element is null. The addAdditionalCssClass()
function continues to apply the extra class to the component. Any suggestions or assistance would be greatly appreciated.