Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 给输入一个动态值emeberjs_Javascript_Ember.js_Ember Cli - Fatal编程技术网

Javascript 给输入一个动态值emeberjs

Javascript 给输入一个动态值emeberjs,javascript,ember.js,ember-cli,Javascript,Ember.js,Ember Cli,所以我有一个遍历余烬模型的each循环: {{#each model.product.variants as |variant|}} {{input type="radio" value=variant.id name="product_id" action="radioChecked" on="focus-in"}} {{/each}} 我想做的是将每个输入的值设置为变量的id,这部分就在这里value=variant.id。现在这似乎是可行的,因为这是一个呈现HTML的示例: &l

所以我有一个遍历余烬模型的each循环:

{{#each model.product.variants as |variant|}}
    {{input type="radio" value=variant.id name="product_id" action="radioChecked" on="focus-in"}}
{{/each}}
我想做的是将每个输入的值设置为
变量的
id
,这部分就在这里
value=variant.id
。现在这似乎是可行的,因为这是一个呈现HTML的示例:

<input id="ember821" name="product_id" type="radio" value="34">

我得到的错误是值未定义。我应该怎么做呢?

值已传入,因此需要在函数定义中定义

function(value){
     console.log('action worked');
     // note this will just be the id, you may want to query your collection
     // and use the object instead of the id...
     this.set('selectedProduct', value);  
}
function(value){
     console.log('action worked');
     // note this will just be the id, you may want to query your collection
     // and use the object instead of the id...
     this.set('selectedProduct', value);  
}