[英]Using If statement with ember in a JS file
I am not sure how this works but i need to put an if statement in the following code. 我不知道这是如何工作的,但我需要在下面的代码中添加一个if语句。 I know Javascript but not ember, still learning it as I go My file is called: CatalogueListController.js and the code with in:
我知道Javascript但不是ember,我仍在学习它我的文件被称为:CatalogueListController.js和代码在:
App.CataloguelistController = Em.ArrayController.extend(Ember.PaginationSupport, {
needs: ["search", "accountBrowse"],
content: [],
total: 0,
isLoading: false,
outofcount: 0,
searchquery: '',
classid: 0,
attributelist: '',
processguid: '',
quotetypeMetaBinding: "App.metaDataController.QUOTETYPE",
addToBulk: function(context) {
var self = this,
accountguid = App.selectedAccountGuid,
quotetype = (context && context.metacode) ? context.metacode : App.currentQuotetype,
itemArray = [];
//some more code here
},
//i need to put the if here if it is for a certain accountguid then have
currentViewList: true,
currentViewBulk: false,
//else have this
currentViewList: false,
currentViewBulk: true,
mainPage: false,
andOr: [
{"name": "Match All", "value": "AND"},
{"name": "Match Any", "value": "OR"}
],
andOrSelected: 'AND',
i have put in comments where i need to have the if. 我已经把评论放在哪里,我需要if。 Any help please?
有什么帮助吗? thanks
谢谢
On init conditionally set those properties: 在init上有条件地设置这些属性:
App.CataloguelistController = Em.ArrayController.extend(Ember.PaginationSupport, {
init: function(){
this._super();
if(//somecondition){
this.set('currentViewList', true);
this.set('currentViewBulk', false);
}else{
// set them to something else..
}
}
You can use computed properties. 您可以使用计算属性。 Also if you ever need to, you can bind computed properties with other properties that may change dynamically.( http://emberjs.com/guides/object-model/computed-properties/ )
此外,如果您需要,可以将计算属性与可能动态更改的其他属性绑定。( http://emberjs.com/guides/object-model/computed-properties/ )
App.CataloguelistController = Em.ArrayController.extend(Ember.PaginationSupport, {
needs: ["search", "accountBrowse"],
.....
currentViewList:function(){
if(/*it is for a certain accountguid*/){
return true;
}else{
return false;
}
}.property(),
currentViewBulk:function(){
if(/*it is for a certain accountguid*/){
return true;
}else{
return false;
}
}.property(),
.....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.