user1492051
user1492051

Reputation: 906

string concat in an html attribute

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?

Upvotes: 2

Views: 9408

Answers (1)

Aviran Cohen
Aviran Cohen

Reputation: 5691

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>'

Upvotes: 4

Related Questions