Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 1137d91

Browse files
committed
docs(ngRepeat): point out animate example, remove ng-init
Closes #9047
1 parent 288e4e3 commit 1137d91

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

src/ng/directive/ngRepeat.js

+24-17
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@
170170
*
171171
* **.move** - when an adjacent item is filtered out causing a reorder or when the item contents are reordered
172172
*
173+
* See the example below for defining CSS animations with ngRepeat.
174+
*
173175
* @element ANY
174176
* @scope
175177
* @priority 1000
@@ -222,22 +224,11 @@
222224
* For example: `item in items | filter : x | orderBy : order | limitTo : limit as results` .
223225
*
224226
* @example
225-
* This example initializes the scope to a list of names and
226-
* then uses `ngRepeat` to display every person:
227-
<example module="ngAnimate" deps="angular-animate.js" animations="true">
227+
* This example uses `ngRepeat` to display a list of people. A filter is used to restrict the displayed
228+
* results by name. New (entering) and removed (leaving) items are animated.
229+
<example module="ngRepeat" name="ngRepeat" deps="angular-animate.js" animations="true">
228230
<file name="index.html">
229-
<div ng-init="friends = [
230-
{name:'John', age:25, gender:'boy'},
231-
{name:'Jessie', age:30, gender:'girl'},
232-
{name:'Johanna', age:28, gender:'girl'},
233-
{name:'Joy', age:15, gender:'girl'},
234-
{name:'Mary', age:28, gender:'girl'},
235-
{name:'Peter', age:95, gender:'boy'},
236-
{name:'Sebastian', age:50, gender:'boy'},
237-
{name:'Erika', age:27, gender:'girl'},
238-
{name:'Patrick', age:40, gender:'boy'},
239-
{name:'Samantha', age:60, gender:'girl'}
240-
]">
231+
<div ng-controller="repeatController">
241232
I have {{friends.length}} friends. They are:
242233
<input type="search" ng-model="q" placeholder="filter friends..." aria-label="filter friends" />
243234
<ul class="example-animate-container">
@@ -250,6 +241,22 @@
250241
</ul>
251242
</div>
252243
</file>
244+
<file name="script.js">
245+
angular.module('ngRepeat', ['ngAnimate']).controller('repeatController', function($scope) {
246+
$scope.friends = [
247+
{name:'John', age:25, gender:'boy'},
248+
{name:'Jessie', age:30, gender:'girl'},
249+
{name:'Johanna', age:28, gender:'girl'},
250+
{name:'Joy', age:15, gender:'girl'},
251+
{name:'Mary', age:28, gender:'girl'},
252+
{name:'Peter', age:95, gender:'boy'},
253+
{name:'Sebastian', age:50, gender:'boy'},
254+
{name:'Erika', age:27, gender:'girl'},
255+
{name:'Patrick', age:40, gender:'boy'},
256+
{name:'Samantha', age:60, gender:'girl'}
257+
];
258+
});
259+
</file>
253260
<file name="animations.css">
254261
.example-animate-container {
255262
background:white;
@@ -260,7 +267,7 @@
260267
}
261268
262269
.animate-repeat {
263-
line-height:40px;
270+
line-height:30px;
264271
list-style:none;
265272
box-sizing:border-box;
266273
}
@@ -282,7 +289,7 @@
282289
.animate-repeat.ng-move.ng-move-active,
283290
.animate-repeat.ng-enter.ng-enter-active {
284291
opacity:1;
285-
max-height:40px;
292+
max-height:30px;
286293
}
287294
</file>
288295
<file name="protractor.js" type="protractor">

0 commit comments

Comments
 (0)