big*_*pon 3 aurelia aurelia-binding
假设我有以下html元素:
<template bindable='value: Math.random()'>
${value}
</template>
<!-- In another component {Main} -->
<template>
<require from='./that-element'></require>
<that-element></that-element>
</template>
Run Code Online (Sandbox Code Playgroud)
结果是主要组件中的空字符串.问题是如何为仅html元素定义默认值?
编辑:如果2个绑定需要具有相同的唯一默认值,则元素的默认值将不起作用.我可以让它自己独一无二,但我必须手动完成它.正在寻找类似的东西Math.random()
标记bindable上的属性内容<template>以逗号分隔的字符串列表处理.因此,您将无法在那里设置默认值.
我可以想到两种方法:
<that-element value.bind="someVarFromParent"></that-element>
${value || 'default value'}
Gist演示:https://gist.run/ ? id = f0698d5b0066c3674c29c40d850217dc