ngShow Example

by Leandro Machado Costa

HTML

<script src="http://code.angularjs.org/1.2.0-rc.2/angular.js"></script>
<div ng-app="app">
    <div ng-controller="MainController">
        <button ng-click="flipMode()">FLIP!</button>
        <div ng-repeat="thing in things">
            <div ng-show="thing.shown">
                 <h3>{{thing.id}}</h3>

            </div>
        </div>
    </div>
</div>

JavaScript

angular.module('app', []).
controller('MainController', ['$scope', function ($scope) {
    $scope.things = [{
        id: 1,
        shown: true
    }, {
        id: 2,
        shown: false
    }, {
        id: 3,
        shown: true
    }, {
        id: 4,
        shown: false
    }, {
        id: 5,
        shown: true
    }, ];
    $scope.flipMode = function () {
        $scope.things.forEach(function (thing) {
            thing.shown = !thing.shown
        })
    };
}]);