Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 20b627c

Browse files
committed
Merge pull request angular#178 from angular/kw-dart-33
Update Dart docs to alpha.33
2 parents a3cee85 + 9edd382 commit 20b627c

File tree

4 files changed

+82
-55
lines changed

4 files changed

+82
-55
lines changed

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

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,10 @@
1818

1919
code-tabs
2020
code-pane(language="dart" name="web/main.dart" format="linenums").
21-
import 'package:angular2/angular2.dart';
22-
import 'package:angular2/src/reflection/reflection.dart' show reflector;
23-
import 'package:angular2/src/reflection/reflection_capabilities.dart'
24-
show ReflectionCapabilities;
25-
21+
import 'package:angular2/bootstrap.dart';
2622
import 'package:displaying_data/show_properties.dart';
2723

2824
main() {
29-
reflector.reflectionCapabilities = new ReflectionCapabilities();
3025
bootstrap(DisplayComponent);
3126
}
3227
code-pane(language="html" name="web/index.html" format="linenums").
@@ -48,7 +43,7 @@
4843
description: Dart version of Angular 2 example, Displaying Data
4944
version: 0.0.1
5045
dependencies:
51-
angular2: 2.0.0-alpha.29
46+
angular2: 2.0.0-alpha.33
5247
browser: ^0.10.0
5348
transformers:
5449
- angular2:
@@ -249,6 +244,7 @@
249244

250245
code-example(language="dart").
251246
// In lib/show_properties.dart
247+
...
252248
<span class="pnk">import 'package:displaying_data/friends_service.dart';</span>
253249
...
254250
class DisplayComponent {
@@ -330,15 +326,10 @@
330326
List&lt;String&gt; names = ['Aarav', 'Martín', 'Shannon', 'Ariana', 'Kai'];
331327
}
332328
code-pane(language="dart" name="web/main.dart" format="linenums").
333-
import 'package:angular2/angular2.dart';
334-
import 'package:angular2/src/reflection/reflection.dart' show reflector;
335-
import 'package:angular2/src/reflection/reflection_capabilities.dart'
336-
show ReflectionCapabilities;
337-
329+
import 'package:angular2/bootstrap.dart';
338330
import 'package:displaying_data/show_properties.dart';
339331

340332
main() {
341-
reflector.reflectionCapabilities = new ReflectionCapabilities();
342333
bootstrap(DisplayComponent);
343334
}
344335
code-pane(language="html" name="web/index.html" format="linenums").
@@ -360,7 +351,7 @@
360351
description: Displaying Data example
361352
version: 0.0.1
362353
dependencies:
363-
angular2: 2.0.0-alpha.29
354+
angular2: 2.0.0-alpha.33
364355
browser: ^0.10.0
365356
transformers:
366357
- angular2:
@@ -438,6 +429,31 @@
438429
library displaying_data.friends_service;
439430
...
440431

432+
p.
433+
The app's entry point—<code>main.dart</code>—imports
434+
<code>bootstrap.dart</code>.
435+
Both <code>show_properties.dart</code> and <code>friends_service.dart</code>
436+
import <code>angular2.dart</code> instead,
437+
because they use Angular APIs but aren't entry points.
438+
(They don't call <code>bootstrap()</code>.)
439+
See <a href="/docs/dart/latest/quickstart.html#performance">Performance,
440+
the transformer, and Angular 2 libraries</a> for more information.
441+
442+
code-example(language="dart").
443+
// In web/main.dart:
444+
import 'package:angular2/bootstrap.dart';
445+
...
446+
447+
// In lib/show_properties.dart:
448+
...
449+
import 'package:angular2/angular2.dart';
450+
...
451+
452+
// In lib/friends_service.dart:
453+
...
454+
import 'package:angular2/angular2.dart';
455+
...
456+
441457
p.
442458
For more information on implementing Dart libraries, see
443459
<a href="https://www.dartlang.org/docs/dart-up-and-running/ch02.html#libraries-and-visibility">Libraries and visibility</a>

public/docs/dart/latest/guide/setup.jade

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
description: Getting Started example
3131
version: 0.0.1
3232
dependencies:
33-
angular2: 2.0.0-alpha.29
33+
angular2: 2.0.0-alpha.33
3434
browser: ^0.10.0
3535
transformers:
3636
- angular2:
@@ -55,17 +55,13 @@
5555

5656
code-example(language="dart" escape="html").
5757
// web/main.dart
58-
import 'package:angular2/angular2.dart';
59-
import 'package:angular2/src/reflection/reflection.dart' show reflector;
60-
import 'package:angular2/src/reflection/reflection_capabilities.dart'
61-
show ReflectionCapabilities;
58+
import 'package:angular2/bootstrap.dart';
6259

6360
@Component(selector: 'my-app')
6461
@View(template: '<h1>My first Angular 2 App</h1>')
6562
class AppComponent {}
6663

6764
main() {
68-
reflector.reflectionCapabilities = new ReflectionCapabilities();
6965
bootstrap(AppComponent);
7066
}
7167

public/docs/dart/latest/guide/user-input.jade

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,10 @@
167167
}
168168
}
169169
code-pane(language="dart" name="web/main.dart" format="linenums").
170-
import 'package:angular2/angular2.dart';
171-
import 'package:angular2/src/reflection/reflection.dart' show reflector;
172-
import 'package:angular2/src/reflection/reflection_capabilities.dart'
173-
show ReflectionCapabilities;
174-
170+
import 'package:angular2/bootstrap.dart';
175171
import 'package:user_input/todo_list.dart';
176172

177173
main() {
178-
reflector.reflectionCapabilities = new ReflectionCapabilities();
179174
bootstrap(TodoList);
180175
}
181176
code-pane(language="html" name="web/index.html" format="linenums").
@@ -197,7 +192,7 @@
197192
description: User Input example
198193
version: 0.0.1
199194
dependencies:
200-
angular2: 2.0.0-alpha.29
195+
angular2: 2.0.0-alpha.33
201196
browser: ^0.10.0
202197
transformers:
203198
- angular2:

public/docs/dart/latest/quickstart.jade

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ p.
3838
specify the angular2 and browser packages as dependencies,
3939
as well as the angular2 transformer.
4040
Angular 2 is changing rapidly, so provide an exact version:
41-
<b>2.0.0-alpha.29</b>.
41+
<b>2.0.0-alpha.33</b>.
4242

4343
code-example(language="yaml" format="linenums").
4444
name: hello_world
4545
version: 0.0.1
4646
dependencies:
47-
angular2: 2.0.0-alpha.29
47+
angular2: 2.0.0-alpha.33
4848
browser: ^0.10.0
4949
transformers:
5050
- angular2:
@@ -73,17 +73,31 @@ p.
7373
&gt; <span class="blk">vim web/main.dart</span> # Use your favorite editor!
7474

7575
p.
76-
Edit <code>web/main.dart</code> to import the angular2 library
77-
and two reflection libraries:
76+
Edit <code>web/main.dart</code> to import the Angular bootstrap library:
7877

7978
code-example(language="dart" format="linenums").
80-
import 'package:angular2/angular2.dart';
81-
import 'package:angular2/src/reflection/reflection.dart' show reflector;
82-
import 'package:angular2/src/reflection/reflection_capabilities.dart'
83-
show ReflectionCapabilities;
79+
import 'package:angular2/bootstrap.dart';
8480
//- STEP 3 - Define a component ##########################
8581
.l-main-section
8682

83+
.l-sub-section
84+
h3 Top-level Angular 2 libraries
85+
86+
p.
87+
The main Dart file for any Angular 2 app must import
88+
<code>'package:angular2/bootstrap.dart'</code>.
89+
If you put part of your app into one or more additional libraries,
90+
those additional libraries must import <code>angular2.dart</code>
91+
instead of <code>bootstrap.dart</code>,
92+
93+
p.
94+
The <code>bootstrap.dart</code> and <code>angular2.dart</code> files
95+
provide the same API,
96+
except that <code>bootstrap.dart</code> also provides a
97+
<code>bootstrap()</code> function, which you'll see a little later.
98+
For <a href="#performance">performance reasons</a>,
99+
use <code>angular2.dart</code> whenever possible.
100+
87101
h2#section-angular-create-account 3. Define a component
88102

89103
p.
@@ -163,7 +177,6 @@ p.
163177

164178
code-example(language="dart" format="linenums:16").
165179
main() {
166-
reflector.reflectionCapabilities = new ReflectionCapabilities();
167180
bootstrap(AppComponent);
168181
}
169182

@@ -173,17 +186,6 @@ p.
173186
The argument to <code>bootstrap()</code> is the name of the component class
174187
you defined above.
175188

176-
p.
177-
Setting the value of <code>reflector.reflectionCapabilities</code>
178-
lets your app use the Dart VM's reflection (dart:mirrors)
179-
when running in Dartium.
180-
Reflection is fast in native Dart,
181-
so using it makes sense during development.
182-
Later, when you build a JavaScript version of your app,
183-
the Angular transformer will
184-
convert the reflection-using code to static code,
185-
so your generated JavaScript can be smaller and faster.
186-
187189

188190
//- STEP 5 - Declare the HTML ##########################
189191
.l-main-section
@@ -245,16 +247,15 @@ p.
245247

246248
code-example(language="basic").
247249
&gt; <span class="blk">pub build</span>
248-
Loading source assets...
249-
Loading angular2 transformers...
250-
INFO: Formatter is being overwritten.
251-
Building hello_world... (4.2s)
250+
Loading source assets...
251+
...
252+
Building hello_world... (5.7s)
252253
[Info from Dart2JS]:
253254
Compiling hello_world|web/main.dart...
254255
[Info from Dart2JS]:
255-
Took 0:00:16.908569 to compile hello_world|web/main.dart.
256-
Built 75 files to "build".
257-
//- REGENERATE THIS OUTPUT - or delete it? - when updating from 2.0.0-alpha.29
256+
Took 0:00:19.177402 to compile hello_world|web/main.dart.
257+
Built 303 files to "build".
258+
//- REGENERATE THIS OUTPUT - or delete it? - when updating from 2.0.0-alpha.33
258259
259260
p.
260261
The generated JavaScript appears, along with supporting files,
@@ -273,7 +274,7 @@ p.
273274
name: hello_world
274275
version: 0.0.1
275276
dependencies:
276-
angular2: 2.0.0-alpha.29
277+
angular2: 2.0.0-alpha.33
277278
browser: ^0.10.0
278279
<span class="pnk">transformers:
279280
- angular2:
@@ -286,6 +287,25 @@ p.
286287
<a href="https://github.com/angular/angular/wiki/Angular-2-Dart-Transformer">Angular
287288
transformer wiki page</a>.
288289

290+
291+
#performance.l-sub-section
292+
h3 Performance, the transformer, and Angular 2 libraries
293+
294+
p.
295+
When you import <code>bootstrap.dart</code>,
296+
you also get <code>dart:mirrors</code>,
297+
a reflection library that
298+
causes performance problems when compiled to JavaScript.
299+
Don't worry,
300+
the Angular transformer converts your entry points
301+
so that they don't use mirrors.
302+
The transformer doesn't convert other libraries in your app,
303+
so be sure to
304+
import <code>angular2.dart</code> instead of <code>bootstrap.dart</code>
305+
in any libraries you create that use Angular 2
306+
but don't call <code>bootstrap()</code>.
307+
308+
289309
//- WHAT'S NEXT... ##########################
290310
.l-main-section
291311
h2#section-transpile Great job! Next step...

0 commit comments

Comments
 (0)