我有一个Ember模板,默认显示5个div。 我的模板配置如下 -
<img class="col-lg-1 scroll-img" src="imgs/left_scroll_arrow.png" {{action 'active-credit-left-scroll'}}/>
{{#each activebrand in limitedContent}}
//HTML content
{{#each activebrand in limitedContent}}
<img class="col-lg-1 scroll-img scroll-right" src="imgs/right_scroll_arrow.png" {{action 'active-credit-right-scroll'}}/>
我通过我的控制器填充模板,如下所示:
export default Ember.Controller.extend({
'activecreditstartVal':0,
'activecreditendVal':5,
actions:{
'active-credit-left-scroll':function(){
if(this.get('activecreditstartVal')>0){
this.set('activecreditstartVal',this.get('activecreditstartVal')-1);
this.set('activecreditendVal',this.get('activecreditendVal')-1);
}
},
'active-credit-right-scroll':function(){
this.set('activecreditstartVal',this.get('activecreditstartVal')+1);
this.set('activecreditendVal',this.get('activecreditendVal')+1);
},
},
limitedContent: function(){
return this.get('model.firstObject.activebrands').slice(this.get('activecreditstartVal'),this.get('activecreditendVal'));
}.property('model.firstObject.activebrands')
});
最初过滤机制有效,只显示0-5记录,但点击右侧滚动按钮我想显示记录1-6。 我检查了activecreditStartVal和activecreditendVal的值是否正在更新,但模板没有得到更新。
我做错了什么? 感谢
答案 0 :(得分:1)
您希望根据limitedContent
和activeCreditStartVal
计算activeCreditEndVal
:
limitedContent: function() {
return //your return code here
}.property('activeBrands', 'activeCreditStartVal', 'activeCreditEndVal')