Apply style on boolean function return

I’m trying to apply a CSS class based on a function that returns a boolean, but I seem unable to do so. Can someone please tell me what i’m doing wrong?

Component:

isActiveSubRoute(parentRoute:Array<Route>){
    var currentRoute = window.location.href.split('/#/')[1];
    parentRoute.forEach(childRoute=> {
        return childRoute.route === currentRoute;
    });
}

HTML:

<ul *ngIf="esMenuItem.children.length > 0" [ngStyle.display]="{isActiveSubRoute(esMenuItem.children) ? 'block' : 'inherit'}">

I’ve also tried with:

{isActiveSubRoute(esMenuItem.children) == true ? 'block' : 'inherit'}"
{isActiveSubRoute(esMenuItem.children) === true ? 'block' : 'inherit'}"

My page goes completely blank and chrome console doesn’t tell me anything either.

Source: Angular

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.