The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

352229 (9) [Avatar] Offline

I am using following sample code for checking ng-if and ng-else.

<html xmlns="">
<head runat="server">
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
        var app = angular.module('app', []);
        app.controller('myController', function ($scope) {
            $scope.Voters = [
            { Name: "Karan", Age: 33 },
            { Name: "Anurag", Age: 16 },
            { Name: "Ritesh", Age: 34 }
    <form id="form1" runat="server">
    <div ng-app="app" ng-controller="myController">
                <tr ng-repeat="voter in Voters">                  
                    <td ng-if="voter.Age >= 18">
                            {{voter.Name}} + {{voter.Age}}
                    <td  ng-else="voter.Age < 18">
                            {{voter.Name + " is not eligible to vote"}} + {{voter.Age}}

But I am getting strange output. Please check the file attached.

My question is why ng-else block is displaying
Lukas Ruebbelke (107) [Avatar] Offline
There is no ng-else. You need to use ng-if and invert your expression i.e. ng-if="!someValue"