使用旧的 Web UI 代码:
<template instantiate="if view == 'dashboard'">
不工作的聚合物代码:
<p>{{view}}</p> <-- this is ok, prints: dashboard
<template if="{{view == 'dashboard'}}"> <-- not work, if I change code to use bool property something like {{showDashboard}} then works ok.
什么是正确的语法?我找不到任何使用字符串比较进行实例化的示例。
* *编辑。更多细节:Dart SDK 版本 0.7.3.1_r27487
html:
<p>int: {{score}}</p>
<template bind if="{{score == 4}}">
<p>ins int: {{score}}</p>
</template>
<p>String: {{view}}</p>
<template bind if="{{view == 'dashboard'}}">
<p>ins String: {{view}}</p>
</template>
<p>bool: {{showp}}</p>
<template bind if="{{showp}}">
<p>ins bool: {{showp}}</p>
</template>
镖:
class AppModel extends Object with ObservableMixin {
@observable String view = "dashboard";
@observable int score = 4;
@observable bool showp = true;
}
void main() {
query("#templ").model = new AppModel();
}
并输出:
int: 4
String: dashboard
bool: true
ins bool: true