I want to access the angular controller property from the same tag where ng-controller is defined and hide the tag using ng-if if the property languages is having less than one element.
To be precise this is what my not working code looks like:
<li ng-controller="LanguageController" ng-if="languages.length > 1">
...
</li>
But if I do something like this then it works.
<li ng-controller="LanguageController">
<div ng-if="languages.length > 1">...</div>
</li>
When I try this
<li ng-controller="LanguageController" data-val="{{languages.length}}">
...
The output is ... data-val="1".. which means
I can access the properties in the root element itself
To add to it, it also works when I use ng-show to hide my root element. Thanks to @sarjan-desai.
Question : But still why doesn't the
ng-if work and remove my root li object, while the ng-show works?