I am new to web dev and AngularJS. I am trying to use the ng directive - if only the div block is displayed, if the list returned from the database is greater than 1, but it does not work. Am I abusing the directive? I looked around and did not find solutions that work. Currently, both divs and ng-ifs are displayed are ignored.
<div>
<div ng-if="listOfThings.length > 1">
<h1> {{listOfThings.length}} </h1>
</br>
<div ng-repeat="thing in listOfThings">
<label> {{ thing.name }} </label>
</div>
</div>
<div ng-if="listOfThings.length == 1" class="col-sm-4 col-sm-offset-4">
<h1> {{ listOfThings[0].name }} </h1>
<iframe width="560" height="315" ng-src="{{ listOfThings[0].embed }}" frameborder="0" allowfullscreen></iframe>
</div>
</div>
I tried this code that works in Plunker, but for some reason not in my code. Only ng-app works in my code, but ng-if still doesn't work.
<div ng-app="ngAnimate">
Click me: <input type="text" ng-model="check" ng-init="check='show'" /><br/>
Show when check: {{check}}
<input ng-if="check!='hide'" class="animate-if" placeholder="type the word 'hide'"/>
</div>
source
share