Passing function with the innerHTML in ng-class

403 views Asked by At

I'm trying to create an ng-class clause in AngularJS that evaluates the length of the contents and assigns a class accordingly, the problem is that the text is retrieved using the angular-translate service, so when trying to pass the variable in the ng-class, it is still undefined.

Here's what I've tried so far

<div ng-class="{'title-long-text': $controller.isTextTooLong(common.title),
                'title': !$controller.isTextTooLong(common.title)}"
     translate>common.title</div>

the JS

this.isTextTooLong = function(text) {
    if (typeof text === 'undefined' || !text) {
        return;
    }
    debugger;
    console.log(text);
    return true;
};

PS : this function is currently for testing purposes only, it is still a work in progress

0

There are 0 answers