Advertisement
Guest User

Untitled

a guest
Nov 10th, 2012
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.38 KB | None | 0 0
  1. <html>
  2. <head>
  3.     <title>hide & show</title>
  4.  
  5.    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js"></script>
  6.    <script type="text/javascript">
  7.        function HideShowCtrl ($scope)
  8.        {
  9.            $scope.boxes =
  10.            [
  11.                {color:"green"},
  12.                {color:"red"},
  13.                {color:"blue"},
  14.                {color:"yellow"},
  15.                {color:"purple"},
  16.                {color:"orange"},
  17.                {color:"brown"}
  18.            ];
  19.             $scope.disableAll = function ()
  20.             {
  21.                 $scope.boxes.forEach(function(b){b.hidden = true})
  22.             }
  23.         }
  24.     </script>
  25.  
  26. </head>
  27. <body ng-app ng-controller="HideShowCtrl">
  28.  
  29. show buttons:
  30. <input ng-repeat="box in boxes"
  31.       value="{{box.color}}"
  32.       ng-click="box.hidden = false"
  33.       ng-disabled="!box.hidden"
  34.       type="button">
  35. |
  36. <input type="button"
  37.       value="hide all"
  38.       name="hide all"
  39.       ng-click="disableAll()">
  40.  
  41. <br><hr>
  42.  
  43. <div ng-repeat="box in boxes"
  44.     style="background-color:{{box.color}};
  45.            width: 100px;
  46.            height: 100px;
  47.            margin: 10px;
  48.            padding: 5px;
  49.            display: {{box.hidden && 'none'|| 'inline-block'}}"
  50.     ng-click="box.hidden = true"
  51.     >
  52.     Click to hide.
  53. </div>
  54.  
  55. </body>
  56. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement