1
votes

I've been playing around with Dart recently and found that it's very comforting language to play with. I try to build a simple web app with pure Dart (no framework like AngularDart or any else) with three pages (login, dashboard, and profile).

I put the login page by modifying the index.html provided by the stagehand command (web-simple), so there is nothing wrong since the main.dart will immediately bind to index.html and I can edit the content within the login page (index.html) through main.dart directly.

What I don't get about was how to bind other pages with dart code. I want to edit or add some interactivity through Dart, but have no idea how to bind those codes with the other html pages beside index.html.

Any help would be much appreciated.

1

1 Answers

0
votes

It's not necessarily the case than main.dart is "bound" to the index.html template, but rather the <script defer src="main.dart.js"></script> in the <head> loads the compiled main.dart file. You can copy the script declaration to the other html pages.

Alternatively, you could use the dart2js tool to compile other dart files for the other pages:

$ dart2js -O2 -o page-2.js page-2.dart

and in the <head> of page 2:

<script defer src="page-2.js"></script>

More details here: https://webdev.dartlang.org/tools/dart2js