kipris kipris - 5 months ago 40
AngularJS Question

Ng-if boolean condition issue

I trying to show button if

isNotRegistered == true
and hide nested links. And if it's
false
hide the button and show links.
Why do in my plunker all links hide?
http://plnkr.co/edit/XpwWyYKpbeUASUJpnDa0?p=preview

Answer

I assume the names would turn into links... Check this out... Kindly correct me if i misinterpreted it.

angular.module("App", [])
  .controller("Ctrl", function($scope){
    $scope.list = [
      {item: '1',
        isNotRegistered: false,
        children: [ 
        {name: '11'},
        {name: '12'}
        ]
      },
      {item: '2',
        isNotRegistered: true,
        children: [ 
        {name: '21'},
        {name: '22'}
        ]
      }
      ];
  });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="App" ng-controller="Ctrl">
    <ul>
      <li ng-repeat="item in list">{{item.item}}
        <ul>
          <li ng-if="item.isNotRegistered" ng-repeat="child in item.children">{{child.name}}</li>
          <button ng-if="!item.isNotRegistered">Click</button>
        </ul>
      </li>
    </ul>
  </div>

Comments