angular repeat

<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: '云南' }];
        })

 

posted on 2018-03-16 15:31  段了的弦  阅读(152)  评论(0编辑  收藏  举报