I was trying to use a JavaScript
expression with ng-if
. However, it didn't do anything. It allways returns false
.
What i tried was following:
ng-if="localStorage.getItem('grid-layout') == 'list'
(if true, show div)
The div
doens't render, because it allways returns false
. The grid-layout value is saved in the localStorage
. This is not the issue.
I checked the documentation on the website. Angular
says the following about ng-if
https://docs.angularjs.org/api/ng/directive/ngIf
If the expression is falsy then the element is removed from the DOM tree. If it is truthy a copy of the compiled element is added to the DOM tree.
Is it possible to use just JavaScript
inside ng-if
? If not, how can i archieve what i was trying to do?