Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html ng-app="test">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body ng-controller="MainCtrl">
  <a href="" ng-click="toggleList()">Toggle List</a>
  <h1>{{list}}</h1>
  <div ng-switch on="list">
  <ul ng-switch-when="childBooks">
    <li ng-repeat="book in childBooks">{{book.name}}</li>
  </ul>
  <ul ng-switch-when="adultBooks">
    <li ng-repeat="book in adultBooks">{{book.name}}</li>
  </ul>
</body>
</html>
 
var app = angular.module('test', []);
app.controller('MainCtrl', function ($scope) {
  $scope.list = 'childBooks';
  
  $scope.childBooks = [{name: 'Dodobird'}, {name: 'Catty Red Hat'}];
  
  $scope.adultBooks = [{name: 'Little Lady'}, {name: 'Johny Doe'}];
  
  $scope.toggleList = function () {
    $scope.list = $scope.list === 'childBooks' ? 'adultBooks' : 'childBooks';
  };
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers