传递参数的if语句上的ember-js操作
ember js action on if statement passing a parameter
我只需要将一个参数传递给特定路由的成员操作。
{{#if isSelected 'filters' filter.id}}class="active"{{/if}}
我在app.js文件中的动作路线定义看起来像这个
App.FooRoute = Ember.Route.extend({
model: (...),
actions : {
(...),
'isSelected' : function(table,obj) {
return this.store.find(table,obj).get('selected');
}
}
});
但我得到了Uncaught Error: Assertion Failed: You must pass exactly one argument to the if helper
我不想为此编写帮助程序,因为代码会更好地组织。。。
如何做到这一点?
答案是:我不能。将一个参数传递给if语句,控制台显示
Uncaught Error: Assertion Failed: You must pass exactly one argument to the if helper
认为,这将是一个很好的功能
编辑我用这几行代码安排了我的需求。
Ember.ObjectController.extend({
actions : {
selectItem : function(table,item){
this.store.find(table,item.id).then(function(obj){
obj.set('selected',!obj.get('selected'));
console.log(obj.get('selected'));
obj.save();
});
},
selectAll : function(table){
this.store.find(table).then(function(obj){
obj.forEach(function(obj){
obj.set('selected',true);
obj.save();
});
});
}
}
});
和我的车把(一部分)
{{#each obj in model.objs}}
<dd {{bind-attr class="obj.selected:active"}}><a {{action "selectItem" 'filter' obj}}>{{obj.name}}</a></dd>
{{/each}}
尝试对象:
{{#if isSelected {table: 'filters', id: filter.id} }}class="active"{{/if}}
相关文章:
- 强制模板刷新ember.js
- Ember.js-接口状态应该存储在哪里
- 如何使用ember.js在操作中传递当前上下文中目标旁边的信息
- Ember.js-定义一个全局函数,该函数可以向操作返回值
- 父操作可防止在 ember.js 中调用提交操作
- Ember.js身份验证操作不起作用
- Ember JS - 从路由操作更新/刷新模型数据
- Ember.js将视图插入应用程序控制器,但使用另一个控制器进行操作
- Ember.js 车把 - 在操作助手中使用变量
- Ember.js映射操作键事件
- Ember.js – 将按钮操作从 #each 循环绑定到其自己的模型
- Ember.js-“;无法对不在DOM中的变形执行操作“;由模板引起
- 传递参数的if语句上的ember-js操作
- Ember.js过滤内容并使用按钮操作
- Ember.js -不能对不在DOM中的变形执行操作
- 正在将操作从组件发送到ember.js中的路由
- 如何在ember.js中将params传递给路由器操作
- Ember.js组件操作未启动
- Ember.js TextField操作提交表单
- 如何在ember js操作中获得龙卷风错误响应