Aureliaは文字列補間です。 string
、number
またはboolean
をその変数にバインドすると、それはone-way
にバインドされます。値変換器で印刷された値にAureliaスロットル
しかし、オブジェクトをバインドして、私が望むようにValueConverter
を使用すると、バインドされたオブジェクトはone-time
になります。
one-time
の代わりにone-way
をバインドするために値コンバータを使用するにはどうすればよいですか。
私は${data | objectPrinter & oneWay}
を使用しようとしましたが、動作しません。
Running code can be found on this gist
app.html
<template>
<div class="row">
<!-- this isn't updated on change -->
<pre>${data | objectPrinter}</pre>
</div>
<input value.two-way="data.branches">
<!-- this gets updated -->
${data.branches}
</template>
app.js
export class App {
data = {
branches: "test"
}
}
export class objectPrinterValueConverter {
toView(obj){
return JSON.stringify(obj, null, 4);
}
}
index.htmlを
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app>
<h1>Loading...</h1>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>