AngularJS instruction ng-repeat
AngularJS exemples
sortie Loop plusieurs titres:
<Body ng-app = "myApp " ng-controller = "myCtrl">
<H1 ng-repeat = "x dans les dossiers"> {{x}} </ h1>
<Script>
var app = de angular.module ( "myApp", []);
app.controller ( "myCtrl", function ($ portée) {
$ Scope.records = [
Le "Tutorial 1"
"Ce tutoriel 2"
Le "Tutorial 3"
Le "Tutorial 4"
]
});
</ Script>
</ Body>
<H1 ng-repeat = "x dans les dossiers"> {{x}} </ h1>
<Script>
var app = de angular.module ( "myApp", []);
app.controller ( "myCtrl", function ($ portée) {
$ Scope.records = [
Le "Tutorial 1"
"Ce tutoriel 2"
Le "Tutorial 3"
Le "Tutorial 4"
]
});
</ Script>
</ Body>
Essayez »
Définition et utilisation
sortie de la boucle d'instructionng-repeat pour un nombre spécifié d'éléments HTML.
Collection doit être un tableau ou un objet.
grammaire
<Element ng-repeat = "expression "> </ element>
Tous les éléments HTML prennent en charge l'instruction.
Paramètre Valeur
valeur | description |
---|---|
expression | Expression définit comment un cycle de collecte. expression Exemple de règle: x in records (key, value) in myObj |
D'autres exemples
AngularJS exemples
L'utilisation d'une boucle de réseau affiche une table:
<Table ng-controller = "myCtrl " border = "1">
<Tr ng-repeat = "x dans les dossiers">
<Td> {{x.Name}} </ td>
<Td> {{x.Country}} </ td>
</ Tr>
</ Table>
<Script>
var app = de angular.module ( "myApp", []);
app.controller ( "myCtrl", function ($ portée) {
$ Scope.records = [
{
"Nom": "Alfreds Futterkiste",
"Pays": "Allemagne"
}, {
"Nom": "Berglunds snabbkop",
"Pays": "Suède"
}, {
"Nom": "Centro comercial Moctezuma",
"Pays": "Mexico"
}, {
"Nom": "Ernst Handel",
"Pays": "Autriche"
}
]
});
</ Script>
<Tr ng-repeat = "x dans les dossiers">
<Td> {{x.Name}} </ td>
<Td> {{x.Country}} </ td>
</ Tr>
</ Table>
<Script>
var app = de angular.module ( "myApp", []);
app.controller ( "myCtrl", function ($ portée) {
$ Scope.records = [
{
"Nom": "Alfreds Futterkiste",
"Pays": "Allemagne"
}, {
"Nom": "Berglunds snabbkop",
"Pays": "Suède"
}, {
"Nom": "Centro comercial Moctezuma",
"Pays": "Mexico"
}, {
"Nom": "Ernst Handel",
"Pays": "Autriche"
}
]
});
</ Script>
Essayez »
AngularJS exemples
Un cycle de la sortie en utilisant la table d'objet:
<Table ng-controller = "myCtrl " border = "1">
<Tr ng-repeat = "( x, y) en myObj">
<Td> {{x}} </ td>
<Td> {{y}} </ td>
</ Tr>
</ Table>
<Script>
var app = de angular.module ( "myApp", []);
app.controller ( "myCtrl", function ($ portée) {
$ Scope.myObj = {
"Nom": "Alfreds Futterkiste",
"Pays": "Allemagne",
"Ville": "Berlin"
}
});
</ Script>
<Tr ng-repeat = "( x, y) en myObj">
<Td> {{x}} </ td>
<Td> {{y}} </ td>
</ Tr>
</ Table>
<Script>
var app = de angular.module ( "myApp", []);
app.controller ( "myCtrl", function ($ portée) {
$ Scope.myObj = {
"Nom": "Alfreds Futterkiste",
"Pays": "Allemagne",
"Ville": "Berlin"
}
});
</ Script>
Essayez »