I am new to dart.
I trying to build the web-ui example on Seth Ladd’s blog. I have created a new application.
My html looks like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Proefje</title>
<link rel="stylesheet" href="Proefje.css">
</head>
<body>
<h1>Hello MDV</h1>
<p>MDV is {{superlative}}</p>
<button id="change-it" on-click="changeIt()">Change</button>
<script type="application/dart" src="Proefje.dart"></script>
<script src="https://dart.googlecode.com/svn/branches/bleeding_edge/dart/client/dart.js"></script>
</body>
</html>
And the dart code like this:
import 'dart:math';
import 'dart:html';
import 'package:web_ui/web_ui.dart'; // not sure about this line
String superlative;
List<String> alternatives = const ['wicked cool', 'sweet', 'fantastic'];
Random random;
main() {
superlative = 'awesome';
random = new Random();
query('#change-it').text = 'Do Change';
}
changeIt() => superlative = alternatives[random.nextInt(alternatives.length)];
And my pubspec.yaml
name: Proefje
description: A sample application
dependencies:
web_ui: any
When I run the app I see the query function changing the text in the button, but the MDV is {{superlative}} is left as is.
Any ideas?
You need to compile your html as described in the Setup section of Seth Ladd’s blog.
Basically you can add a
build.dartin your root directory with somthing like :(see Tools for Web UI )