Angular: List name
http://angularjs.org/
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="listController">
<ul>
<li ng-repeat="p in patients">{{p.name}} <button ng-click="removePatient($index)">remove</button></li>
</ul>
<input type="text" ng-model="patient"><button ng-click="addPatient()">add</button>
</div>
<div>{{patients[0]}}</div>
JavaScript
angular.module('myApp',[]).
controller("listController", ["$scope", function($scope) {
$scope.patients = [
{name: "Jean Dupont"},
{name: "Pierre Merti"},
{name: "Jacques Egard"},
{name: "Philippe Petit"},
{name: "Albert Partin"}
];
$scope.patient;
$scope.addPatient = function() {
$scope.patients.push({name: $scope.patient});
$scope.patient = null;
};
$scope.removePatient = function(i) {
$scope.patients.splice(i,1);
};
}]);