clarify/improve imports & import discussion

This commit is contained in:
Kathy Walrath 2015-09-30 17:19:11 -07:00 committed by Naomi Black
parent 9907ef265e
commit f293d61875
2 changed files with 19 additions and 10 deletions

View File

@ -18,7 +18,6 @@
code-tabs
code-pane(language="dart" name="web/main.dart" format="linenums").
import 'package:angular2/angular2.dart';
import 'package:angular2/bootstrap.dart';
import 'package:displaying_data/show_properties.dart';
@ -50,9 +49,14 @@
entry_points: web/main.dart
p.
All of this code should look familiar from the previous page,
except for the import of <code>show_properties.dart</code>
in <code>main.dart</code>.
That import statement lets you implement part of the app in a different Dart file.
except for the imports in <code>main.dart</code>.
The import of <code>show_properties.dart</code>
lets you implement part of the app in a different Dart file.
You've previously seen <code>angular2.dart</code> imported,
but that's unnecessary here because this version of <code>main.dart</code>
doesn't implement any components or other injectable types.
p.
All three of these files remain similar in the rest of the examples,
so we'll focus on what changes.
@ -325,7 +329,6 @@
List&lt;String&gt; names = ['Aarav', 'Martín', 'Shannon', 'Ariana', 'Kai'];
}
code-pane(language="dart" name="web/main.dart" format="linenums").
import 'package:angular2/angular2.dart';
import 'package:angular2/bootstrap.dart';
import 'package:displaying_data/show_properties.dart';
@ -430,26 +433,33 @@
p.
The app's entry point—<code>main.dart</code>—imports
<code>angular2.dart</code> and <code>bootstrap.dart</code>.
<code>bootstrap.dart</code> so that it can call <code>bootstrap()</code>.
Both <code>show_properties.dart</code> and <code>friends_service.dart</code>
import only <code>angular2.dart</code>
because they aren't entry points.
import <code>angular2.dart</code>
so that they can define Angular components and models.
code-example(language="dart").
// In web/main.dart:
import 'package:angular2/angular2.dart';
import 'package:angular2/bootstrap.dart';
...
bootstrap(...)
...
// In lib/show_properties.dart:
...
import 'package:angular2/angular2.dart';
...
@Component(...)
@View(...)
...
// In lib/friends_service.dart:
...
import 'package:angular2/angular2.dart';
...
@Injectable()
...
p.
For more information on implementing Dart libraries, see

View File

@ -167,7 +167,6 @@
}
}
code-pane(language="dart" name="web/main.dart" format="linenums").
import 'package:angular2/angular2.dart';
import 'package:angular2/bootstrap.dart';
import 'package:user_input/todo_list.dart';