2

in my directive i have a template like the following

template:'<li ui-sref-active="active" ng-class="\'has\'+ getSubClassString(item)">'+
            '<a ui-sref="{{item.state}}">' +
            '<span ng-class="getSubClassString(item) + \'-menu-text\'">{{item.content}}                </span>' +
            '</a>' +
            '</li>'

in the ng-class attributes i am trying to concat a string with a function that returns a string, but it doesn't seem to be working, what am i doing wrong?

1 Answer 1

4

Try adding {{ }} so the function will be called and its result will be calculated instead of having the function name as a string.

Try the following code:

template:'<li ui-sref-active="active" ng-class="\'has\'+ getSubClassString(item)">'+
            '<a ui-sref="{{item.state}}">' +
            '<span ng-class="{{getSubClassString(item)}} + \'-menu-text\'">{{item.content}}                </span>' +
            '</a>' +
            '</li>'
Sign up to request clarification or add additional context in comments.

1 Comment

thanks a lot that helped but i had to include the whole attribute value inside {{}} for it to work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.