去'up'范围内的流星烈焰?
Go 'up' scope in meteor blaze?
如何在 Blaze 的当前作用域以上的作用域中使用变量?
例如:
<template name="userLayoutEditCreate">
{{#each findUser id}}
<h3>I am a single user (edit/create)</h3>
<h3>{{id}}</h3>
<form action="/" method="post">
<fieldset>
<!-- Primary instruments multi-select -->
<div class="form-group">
<label class="control-label" for="playerPrimaryInstrument">Primary instruments</label>
<div class="controls text-left">
<select id="playerPrimaryInstrument" name="playerPrimaryInstrument">
{{#each instruments}}
<option value="{{name}}" {{#if equals primary_instrument name}} selected="selected" {{/if}}>{{name}}</option>
{{/each}}
</select>
</div>
</div>
</fieldset>
</form>
{{/each}}
</template>
if 语句不在每个块中 运行。但它确实 运行 在每个块之外(我已经定义了助手)。
我得到的错误看起来像这样。
Reactive HTML attributes must either have a constant name or consist of a single {{helper}} providing a dictionary of names and values. A template tag of type BLOCKOPEN is not allowed here.
==== 编辑 ====
即使使用“../”范围定义在这种情况下也不起作用。 DID 的工作是将表达式放入所选属性的值中。我不确定这是为什么,如果您有任何想法,请告诉我?
解决方法:
{{#each instruments}}
<option value="{{name}}" selected="{{#if equals name ../primary_instrument}} selected {{/if}}">{{name}}</option>
{{/each}}
试试这个:
{{#if equals ../primary_instrument name}}
{{/if}}
如何在 Blaze 的当前作用域以上的作用域中使用变量?
例如:
<template name="userLayoutEditCreate">
{{#each findUser id}}
<h3>I am a single user (edit/create)</h3>
<h3>{{id}}</h3>
<form action="/" method="post">
<fieldset>
<!-- Primary instruments multi-select -->
<div class="form-group">
<label class="control-label" for="playerPrimaryInstrument">Primary instruments</label>
<div class="controls text-left">
<select id="playerPrimaryInstrument" name="playerPrimaryInstrument">
{{#each instruments}}
<option value="{{name}}" {{#if equals primary_instrument name}} selected="selected" {{/if}}>{{name}}</option>
{{/each}}
</select>
</div>
</div>
</fieldset>
</form>
{{/each}}
</template>
if 语句不在每个块中 运行。但它确实 运行 在每个块之外(我已经定义了助手)。
我得到的错误看起来像这样。
Reactive HTML attributes must either have a constant name or consist of a single {{helper}} providing a dictionary of names and values. A template tag of type BLOCKOPEN is not allowed here.
==== 编辑 ====
即使使用“../”范围定义在这种情况下也不起作用。 DID 的工作是将表达式放入所选属性的值中。我不确定这是为什么,如果您有任何想法,请告诉我?
解决方法:
{{#each instruments}}
<option value="{{name}}" selected="{{#if equals name ../primary_instrument}} selected {{/if}}">{{name}}</option>
{{/each}}
试试这个:
{{#if equals ../primary_instrument name}}
{{/if}}