Latest web development tutorials

Angularjs instrukcja ng-repeat

Instrukcja angularjs referencyjny Instrukcja angularjs referencyjny


angularjs przykłady

Wyjście pętli wielokrotne tytuły:

<Body ng-app = "myApp " NG-controller = "myCtrl">

<H1 ng-repeat = "x w rekordach"> {{x}} </ h1>

<Script>
var app = angular.module ( "myApp", []);
app.controller ( "myCtrl", function ($ zakres) {
$ Scope.records = [
W "Tutorial 1"
"Ten tutorial 2"
W "Tutorial 3"
W "Tutorial 4"
]
});
</ Script>

</ Body>

Spróbuj »

Definicja i Wykorzystanie

ng-repeat wyjście pętli instrukcja dla określonej liczby elementów HTML.

Kolekcja musi być tablicą lub obiekt.


gramatyka

<Element ng-repeat = "Wyrażenie "> </ element>

Wszystkie elementy HTML obsługuje instrukcji.


parametr Wartość

wartość opis
wyrażenie Wyrażenie określa sposób cykl zbierania.

Wyrażenie Przykład zasada:

x in records

(key, value) in myObj

x in records track by $id(x)

Więcej przykładów

angularjs przykłady

Korzystanie z pętli tablicy generuje tabelę:

<Tabela ng-controller = "myCtrl " border = "1">
<Tr ng-repeat = "x w rekordach">
<Td> {{x.Name}} </ td>
<Td> {{x.Country}} </ td>
</ Tr>
</ Table>

<Script>
var app = angular.module ( "myApp", []);
app.controller ( "myCtrl", function ($ zakres) {
$ Scope.records = [
{
"Nazwa": "Alfreds Futterkiste"
"Kraj": "Niemcy"
}, {
"Nazwa": "Berglunds snabbkop"
"Kraj": "Szwecja"
}, {
"Nazwa": "Centro Comercial Montezumy",
"Kraj": "Meksyk"
}, {
"Nazwa": "Ernst Handel"
"Kraj": "Austria"
}
]
});
</ Script>

Spróbuj »

angularjs przykłady

Cykl wyjścia z wykorzystaniem tablicy obiektu:

<Tabela ng-controller = "myCtrl " border = "1">
<Tr ng-repeat = "( x, y) w myObj">
<Td> {{x}} </ td>
<Td> {{r}} </ td>
</ Tr>
</ Table>

<Script>
var app = angular.module ( "myApp", []);
app.controller ( "myCtrl", function ($ zakres) {
$ Scope.myObj = {
"Nazwa": "Alfreds Futterkiste"
"Kraj": "Niemcy",
"Miasto": "Berlin"
}
});
</ Script>

Spróbuj »

Instrukcja angularjs referencyjny Instrukcja angularjs referencyjny