Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit d61e884

Browse files
SamVerschuerennaomiblack
authored andcommitted
Change all the For and If directives to NgFor and NgIf
1 parent 253d29b commit d61e884

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

public/docs/js/latest/guide/displaying-data.jade

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
want to move them to a separate file and load them with <code>templateUrl:</code> instead.
105105

106106
.l-main-section
107-
h2#Create-an-array Create an array property and use For on the view
107+
h2#Create-an-array Create an array property and use NgFor on the view
108108
p Moving up from a single property, create an array to display as a list.
109109

110110
code-tabs
@@ -127,7 +127,7 @@
127127
<span class='otl'>this.names = ["Aarav", "Martín", "Shannon", "Ariana", "Kai"];</span>
128128
}
129129
p.
130-
You can then use this array in your template with the <code>For</code> directive to create copies of DOM elements
130+
You can then use this array in your template with the <code>NgFor</code> directive to create copies of DOM elements
131131
with one for each item in the array.
132132

133133
code-tabs
@@ -137,7 +137,7 @@
137137
&lt;p&gt;My name: {{ myName }}&lt;/p&gt;
138138
&lt;p&gt;Friends:&lt;/p&gt;
139139
&lt;ul&gt;
140-
&lt;li *for=&quot;#name of names&quot;&gt;
140+
&lt;li *ng-for=&quot;#name of names&quot;&gt;
141141
{{ name }}
142142
&lt;/li&gt;
143143
&lt;/ul&gt;
@@ -148,22 +148,22 @@
148148
&#39;&lt;p&gt;My name: {{ myName }}&lt;/p&gt;&#39; +
149149
&#39;&lt;p&gt;Friends:&lt;/p&gt;&#39; +
150150
&#39;&lt;ul&gt;&#39; +
151-
&#39;&lt;li *for=&quot;#name of names&quot;&gt;&#39; +
151+
&#39;&lt;li *ng-for=&quot;#name of names&quot;&gt;&#39; +
152152
&#39;{{ name }}&#39; +
153153
&#39;&lt;/li&gt;&#39; +
154154
&#39;&lt;/ul&gt;&#39;,
155155

156156
p.
157-
To make this work, you'll also need to add the <code>For</code> directive used by the template so
157+
To make this work, you'll also need to add the <code>NgFor</code> directive used by the template so
158158
that Angular knows to include it:
159159

160160
code-tabs
161161
code-pane(language="javascript" name="TypeScript" format="linenums").
162162
//Typescript
163-
import {Component, View, bootstrap, For} from 'angular2/angular2';
163+
import {Component, View, bootstrap, NgFor} from 'angular2/angular2';
164164
@View({
165165
...
166-
directives: [For]
166+
directives: [NgFor]
167167
})
168168

169169

@@ -173,7 +173,7 @@
173173
...
174174
new angular.ViewAnnotation({
175175
...
176-
directives: [angular.For]
176+
directives: [angular.NgFor]
177177
})
178178
];
179179

@@ -185,13 +185,13 @@
185185
p Let's look at the few lines that do the work again:
186186
code-example(language="html" format="linenums").
187187
//HTML
188-
&lt;li *for=&quot;#name of names&quot;&gt;
188+
&lt;li *ng-for=&quot;#name of names&quot;&gt;
189189
{{ name }}
190190
&lt;/li&gt;
191191
p The way to read this is:
192192
ul
193193
li.
194-
<code>*for</code> : create a DOM element for each item in an
194+
<code>*ng-for</code> : create a DOM element for each item in an
195195
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols">iterable</a>
196196
like an array
197197
li <code>#name</code> : refer to individual values of the iterable as 'name'
@@ -236,7 +236,7 @@
236236
code-pane(language="javascript" name="TypeScript" format="linenums").
237237
@Component({
238238
...
239-
<span class='otl'>injectables: [FriendsService]</span>
239+
<span class='otl'>appInjector: [FriendsService]</span>
240240
})
241241
class DisplayComponent {
242242
myName: string;
@@ -257,58 +257,58 @@
257257
DisplayComponent.annotations = [
258258
new angular.ComponentAnnotation({
259259
selector: "display",
260-
<span class='otl'>injectables: [FriendsService]</span>
260+
<span class='otl'>appInjector: [FriendsService]</span>
261261
}),
262262
new angular.ViewAnnotation({
263263
template: '{{ myName }} &lt;ul&gt; &lt;li *for="#name of names"&gt;{{ name }}&lt;/li&gt; &lt;/ul&gt;',
264-
directives: [angular.For]
264+
directives: [angular.NgFor]
265265
})
266266
];
267267
<span class='otl'>DisplayComponent.parameters = [[FriendsService]];</span>
268268
document.addEventListener("DOMContentLoaded", function() {
269269
angular.bootstrap(DisplayComponent);
270270
});
271271
.l-main-section
272-
h2#Conditionally-displaying-data-with-If Conditionally displaying data with If
272+
h2#Conditionally-displaying-data-with-NgIf Conditionally displaying data with NgIf
273273
p.
274-
Lastly, before we move on, let's handle showing parts of our UI conditionally with <code>If</code>. The
275-
<code>If</code> directive adds or removes elements from the DOM based on the expression you provide.
274+
Lastly, before we move on, let's handle showing parts of our UI conditionally with <code>NgIf</code>. The
275+
<code>NgIf</code> directive adds or removes elements from the DOM based on the expression you provide.
276276
p See it in action by adding a paragraph at the end of your template
277277
pre.prettyprint.lang-html
278278
code.
279-
&lt;p *if=&quot;names.length &gt; 3&quot;&gt;You have many friends!&lt;/p&gt;
280-
p You'll also need to add the <code>If</code> directive so Angular knows to include it.
279+
&lt;p *ng-if=&quot;names.length &gt; 3&quot;&gt;You have many friends!&lt;/p&gt;
280+
p You'll also need to add the <code>NgIf</code> directive so Angular knows to include it.
281281

282282
code-tabs
283283
code-pane(language="javascript" name="TypeScript" format="linenums").
284284
//Typescript
285-
import {Component, View, bootstrap, For, If} from 'angular2/angular2';
285+
import {Component, View, bootstrap, NgFor, NgIf} from 'angular2/angular2';
286286
...
287-
directives: [For, If]
287+
directives: [NgFor, NgIf]
288288
code-pane(language="javascript" name="ES5" format="linenums").
289289
//ES5
290-
directives: [angular.For, angular.If]
290+
directives: [angular.NgFor, angular.NgIf]
291291
p.
292292
As there are currently 6 items in the list, you'll see the message congratulating you on your many friends.
293293
Remove three items from the list, reload your browser, and see that the message no longer displays.
294294

295295
code-tabs
296296
code-pane(language="javascript" name="TypeScript" format="linenums").
297297
//TypeScript
298-
import {Component, View, bootstrap, For, If} from 'angular2/angular2';
298+
import {Component, View, bootstrap, NgFor, NgIf} from 'angular2/angular2';
299299
...
300300
@View({
301301
<span class='otl'>template</span>: `
302302
&lt;p&gt;My name: {{ myName }}&lt;/p&gt;
303303
&lt;p&gt;Friends:&lt;/p&gt;
304304
&lt;ul&gt;
305-
&lt;li *for=&quot;#name of names&quot;&gt;
305+
&lt;li *ng-for=&quot;#name of names&quot;&gt;
306306
{{ name }}
307307
&lt;/li&gt;
308308
&lt;/ul&gt;
309-
&lt;p *if=&quot;names.length &gt; 3&quot;&gt;You have many friends!&lt;/p&gt;
309+
&lt;p *ng-if=&quot;names.length &gt; 3&quot;&gt;You have many friends!&lt;/p&gt;
310310
`,
311-
directives: [For, If]
311+
directives: [NgFor, NgIf]
312312
})
313313
class DisplayComponent {
314314
...
@@ -333,12 +333,12 @@
333333
&#39;&lt;p&gt;My name: {{ myName }}&lt;/p&gt;&#39; +
334334
&#39;&lt;p&gt;Friends:&lt;/p&gt;&#39; +
335335
&#39;&lt;ul&gt;&#39; +
336-
&#39;&lt;li *for=&quot;#name of names&quot;&gt;&#39; +
336+
&#39;&lt;li *ng-for=&quot;#name of names&quot;&gt;&#39; +
337337
&#39;{{ name }}&#39; +
338338
&#39;&lt;/li&gt;&#39; +
339339
&#39;&lt;/ul&gt;&#39; +
340-
&#39;&lt;p *if=&quot;names.length &gt; 3&quot;&gt;You have many friends!&lt;/p&gt;&#39;',
341-
directives: [angular.For, angular.If]
340+
&#39;&lt;p *ng-if=&quot;names.length &gt; 3&quot;&gt;You have many friends!&lt;/p&gt;&#39;',
341+
directives: [angular.NgFor, angular.NgIf]
342342
})
343343
];
344344

0 commit comments

Comments
 (0)