سؤال

Here is a simple jsfiddle. I'm trying to add the class-names a and b, but what I get is an empty class. For example, if I change it to

{{ bindAttr class="str:a:b}}

I get a Furthermore, is it possible to add some other (default) classnames too ?

{{ bindAttr class"str className1 className2"}}
هل كانت مفيدة؟

المحلول

Of course! Your syntax is just a bit wrong. The syntax for adding a default class is only :className. Here is a simple jsfiddle to show you.

What your first line of code actually states is that if str is true, then assign class 'a' to the element, otherwise class 'b' (which is why you only get 'a' as the assigned class). An example of conditional classes is in an updated version of your jsfiddle here.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top