Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html ng-app="someApp">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <div ng-controller="peopleList">
    
    <h5>Invited</h5>
    <div ng-repeat="person in people.invited  track by person.personID">
      <a href="" ng-click="toggleAttending(person)">
        {{person.first_name}}{{person.last_name}} - {{person.attending}}
      </a>
    </div>
    
    <h5>Attending</h5>
     <div ng-repeat="person in people.attending  track by person.personID">
       <a href="" ng-click="toggleAttending(person)">
        {{person.first_name}}{{person.last_name}} - {{person.attending}}
      </a>
    </div>
    
  </div>
</body>
</html>
 
var someApp = angular.module('someApp', []);
someApp.controller('peopleList', ['$scope', function($scope) {
  var people = [
        {
        "personID": 1,
        "first_name": "Sam",
        "last_name": "Stimpson",
        "attending": false
        },
        {
        "personID": 2,
        "first_name": "Alison",
        "last_name": "van Schoor",
        "attending": true
        },
        {
        "personID": 3,
        "first_name": "Lindsay",
        "last_name": "van Schoor",
        "attending": false
        }
    ];
  
     
    $scope.people = {invited:[], attending:[]};
    updatePeopleAttendance();
    $scope.toggleAttending = function(person) {
      person.attending = !person.attending;
      updatePeopleAttendance();
    };
  
   function updatePeopleAttendance(){
    $scope.people.attending = [];
    $scope.people.invited = [];
     
    angular.forEach(people, function(person){
      $scope.people[person.attending ? 'attending' : 'invited'].push(person);
    });
     
  }
}]);
 
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers