Angular Directive Ng-if Does Not Evaluate Conditional Statement
I'm new to web dev and AngularJS. I'm trying to use the directive ng-if to only display a div block if a list returned from the database is greater than 1, but it's not working. Am
Solution 1:
What you want instead of this ng-if="{{listOfThings.length}} > 1"
is this:
ng-if="listOfThings.length>1"
ng-if
will evaluate the expression.
Check this Online Demo
Solution 2:
This should do
<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>
Post a Comment for "Angular Directive Ng-if Does Not Evaluate Conditional Statement"