Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A string prefix in ng-class

ng-class="{{'tabs-'+currentStyle.value}}"

ng-class="'tabs-'{{currentStyle.value}}"

ng-class="tabs-{{currentStyle.value}}"

i am trying to apply a class based on a value, i tried all of the above and i always get

Error: [$parse:syntax] Syntax Error: Token 'undefined' not a primary expression at column null of the expression [tabs-] starting at [tabs-].

what am i doing wrong?

i simply want the result to be class="tabs-currentStyle.value" without having to declare an extra variable in the scope

like image 313
user1590636 Avatar asked Jun 30 '26 08:06

user1590636


1 Answers

This also works:

ng-class="['tabs-'+currentStyle.value]">

Just tried it in Dalorzo's online demo.

like image 55
Foo L Avatar answered Jul 02 '26 21:07

Foo L