ng-repeat

ng-repeat可以循环输出元素。

<html ng-app="myApp">
 <div ng-controller="studentController"> <h1>{{name}}</h1> <div class="list-group" ng-repeat="x in classes"> <a href="" class="list-group-item">{{x.name}}</a> </div> </div>
var app = angular.module('myApp', []);
var classes = [{name:'语文'}, {name:'数学'}, {name:'英语'}];
app.controller('studentController', function ($scope) {
  $scope.name = "test";
  $scope.classes = classes;
})

加入bootstrap样式之后就可以看到这般效果
ng-repeat_第1张图片

你可能感兴趣的:(ng-repeat)