Dart アプリを作成し、天気 API ソースから天気情報を取得しました。
好奇心から、気象情報をオブジェクトにカプセル化し、Polymer テンプレートでオブジェクトのプロパティをレンダリングできるかどうかをテストしたいと思います。
スニペットは次のようなものです。
HTML ファイル:
<polymer-element ...>
<template>
Today in {{weather.city}}, the temperature is {{weather.temp}}.
</template>
</polymer-element>
および Dart ファイル:
@published Weather weather;
...
weather=new Weather.created(a_json_string);
class Weather
{
String city;
num temp;
// The constructor just creates an instance by extracting the city, temp info fromthe JSON string
}
Dartium では、問題なく動作します。
ただし、そのアプリをビルドしてその出力 HTML ファイルを実行しようとすると、まったく表示されません。