<body ng-app="aj" ng-cloak> <form id="form1" runat="server" ng-controller="ctrl"> <ul style="list-style:none;"> <li ng-if="!$last" ng-class="{'selected':$first}" ng-repeat="a in list">{{$index+1+"."+a.item}} <input type="button" value="删除" ng-click="list.splice($index,1)" /> </li> </ul> </form> </body>
内容于JS中:
angular.module('aj', []) .controller('ctrl', function ($scope) { $scope.list = [{ id: 1, item: '苏州' }, { id: 2, item: '杭州' }, { id: 3, item: '云南' }]; })