I'm using ng-show
as shown below:
<data-ng-show={{entity.primary}}===true>
The value of entity.primary
can be either true
or false
. I am getting the following error in the console:
Syntax Error: Token 'false' is at column {2} of the expression [{3}] starting at [{4}].
How can this error be fixed?
Sadly, your code is a concentrate of errors:
ngShow
directive can only be used as an attribute, and not as an element, as shown by the documentation and the code.ngShow
directive expects an "expression", which is (by and large) standard JavaScript code: you don't need additional curly brackets.=
in your attribute, quotes are mandatory around its value, as explained by this W3C note.Therefore, the correct code is:
<div data-ng-show="entity.primary === true"></div>
ng-show
evaluates an expression. you don't need braces.
try this:
<data-ng-show="entity.primary"></div>
or this:
<data-ng-show="entity.primary === true"></div>
You should add expressions inside the curly braces but not for ng-show <data-ng-show="entity.primary === true"></div>
.
However ng-show evaluates to either true or false depending on it's set value, so you should just do this
<data-ng-show="entity.primary"></div>
And if you need to display the values, you could just add this somewhere
<div>{{entity.primary}}</div>
=> returns true or false or whatever value assigned to it.
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