私は<template is="dom-if" if=...
を論理条件で使いたいと思っています。<template is = "dom-if"を条件付きで使用する
私がしようと、任意の結合がtruthyように表示されます。
<link href="https://polygit.org/components/polymer/polymer.html" rel="import">
<dom-module id="test-thing">
<template>
<template is="dom-if" if="{{title == 'foo'}}" restamp>
Title is <b>FOO</b>
</template>
<template is="dom-if" if="{{title}} == 'bar'" restamp>
Title is <b>BAR</b>
</template>
Actual: "{{title}}"
</template>
<script>
Polymer({
is: 'test-thing',
properties: {
title: {type: String,value:''}
}
});
</script>
</dom-module>
<div>
Title: foo<br>
<test-thing title="foo"></test-thing>
</div>
<div>
Title: bar<br>
<test-thing title="bar"></test-thing>
</div>
<div>
Title: abc<br>
<test-thing title="abc"></test-thing>
</div>
dom-if
template
からif
条件を適用する正しい方法は何ですか?
おかげクバを - 私は関数内で条件をラップまたは関連するプロパティが変更されたときに設定されたプロパティを追加することができることを認識し、それは本当にだけです方法? 'if'ブロックが' if'を評価できるように関数を抽出するのは非常に厄介です。 – Keith
他の方法はありません。プロパティの 'computed'オプションや' observer'オプションも使用できます。しかし、{{title == 'foo'}}のようなものはありません。あなたはそれに慣れなければなりません。私はポリマーの前にハンドルバーを使用していました。最初は私にとっては迷惑でした。 –