I have a list of objects. They are displayed with ngRepeat
direcitve. Each block with information is covered with directive, that has some helper methods.
i.e. it constructs labelId
variable, that is used in this block with one way binding.
So when I want to display it for example in for
attribute I have no problem
{{::label}}
.
When I want to display it as field name, there is also no problem {{::label}}
.
But when I want to reference it in ngMessages
block like:
<p class="error-message" ng-messages="FormName[::label + '_' + $index].$error" ng-messages-include="error-messages.html"></p>
Or when I want to use it for reference to set css class dynamically like:
<div ng-class="{'has-error': (FormName[::label + '_' + $index].$error.someErrorName)}">
then I'm getting Error
Error: [$parse:syntax] Syntax Error: Token ':' not a primary expression at column 21 of the expression [{'has-error': (FormName[::label + '_' + $index].$error
ng-class has one way binding syntax too
ng-class="::{'has-error': ..., 'no-error': ...}"
But it is one expression even if there is many classes inside.
So if you need two-way binding for some classes inside that ng-class, then one way binding cannot be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With