中文字幕一区二区人妻电影,亚洲av无码一区二区乱子伦as ,亚洲精品无码永久在线观看,亚洲成aⅴ人片久青草影院按摩,亚洲黑人巨大videos

AngularJS ng-repeat 指令

AngularJS 參考手冊 AngularJS 參考手冊


AngularJS 實(shí)例

循環(huán)輸出多個(gè)標(biāo)題:

<body ng-app="myApp" ng-controller="myCtrl">

<h1 ng-repeat="x in records">{{x}}</h1>

<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
??? $scope.records = [
??????? "小白教程1",
??????? "小白教程2",
??????? "小白教程3",
??????? "小白教程4",
??? ]
});
</script>

</body>

運(yùn)行代碼 ?

定義和用法

ng-repeat 指令用于循環(huán)輸出指定次數(shù)的 HTML 元素。

集合必須是數(shù)組或?qū)ο蟆?/p>


語法

<element ng-repeat="expression"></element>

所有的 HTML 元素都支持該指令。


參數(shù)值

描述
expression 表達(dá)式定義了如何循環(huán)集合。

表達(dá)式實(shí)例規(guī)則:

x in records

(key, value) in myObj

x in records track by $id(x)

更多實(shí)例

AngularJS 實(shí)例

使用數(shù)組循環(huán)輸出一個(gè)表格:

<table ng-controller="myCtrl" border="1">
??? <tr ng-repeat="x in records">
??????? <td>{{x.Name}}</td>
??????? <td>{{x.Country}}</td>
??? </tr>
</table>

<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
??? $scope.records = [
?????? {
??????????? "Name" : "Alfreds Futterkiste",
??????????? "Country" : "Germany"
??????? },{
??????????? "Name" : "Berglunds snabbk?p",
??????????? "Country" : "Sweden"
??????? },{
??????????? "Name" : "Centro comercial Moctezuma",
??????????? "Country" : "Mexico"
??????? },{
??????????? "Name" : "Ernst Handel",
??????????? "Country" : "Austria"
??????? }
??? ]
});
</script>

運(yùn)行代碼 ?

AngularJS 實(shí)例

使用對象循環(huán)輸出一個(gè)表格:

<table ng-controller="myCtrl" border="1">
??? <tr ng-repeat="(x, y) in myObj">
??????? <td>{{x}}</td>
??????? <td>{{y}}</td>
??? </tr>
</table>

<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
??? $scope.myObj = {
??????? "Name" : "Alfreds Futterkiste",
??????? "Country" : "Germany",
??????? "City" : "Berlin"
??? }
});
</script>

運(yùn)行代碼 ?

AngularJS 參考手冊 AngularJS 參考手冊

其他擴(kuò)展