有谁知道“如何从同一闪电组件内的另一个功能调用闪电控制器功能?” 谢谢 阿鲁纳
({
doInit: function(component, event, helper){
var action = component.get("c.gettemps");
action.setParams({ recordId : component.get("v.recordId") });
action.setCallback(this, function(response){
var parsedJSON= JSON.parse(response.getReturnValue());
var size=component.get("v.limit");
var counter = component.get("v.counter");
component.set("{!v.myObject}",parsedJSON);
var list=[];
for(var i=0; i<size;i++)
{
list.push(parsedJSON[i]);
counter++;
}
component.set("v.end",counter);
component.set("{!v.counter}",counter);
component.set("{!v.paginationList}",list);
});
$A.enqueueAction(action);
},
next:function(component,event,helper)
{
var myObject = component.get("v.myObject");
var size=component.get("v.limit");
var end = component.get("v.end");
var counter = component.get("v.counter");
var list=[];
for(var i=end; i<end+size; i++)
{
if(i<myObject.length)
{
if(i>-1)
{
list.push(myObject[i]);
counter++;
}
}
}
component.set("v.end",counter);
component.set("{!v.counter}",counter);
component.set("{!v.paginationList}",list);
},
previous:function(component,event,helper)
{
var myObject = component.get("v.myObject");
var size=component.get("v.limit");
var end = component.get("v.end");
var counter = component.get("v.counter");
var list=[];
for(var i=end-1; i>end-size-1; i--)
{
if(i>=-1)
{
list.push(myObject[i-1]);
counter--;
}
}
component.set("v.end",counter);
component.set("{!v.counter}",counter);
component.set("{!v.paginationList}",list);
}
})
其实我以前的功能有问题。当我留在我的第一页并选择上一个按钮时,我的页面不应该被更改,但我的代码表现异常。所以当我已经在第一页时,我想到重用我的doInit函数来保留当前页面。请帮忙 谢谢 阿鲁纳
答案 0 :(得分:0)
在帮助器中,可以通过“this”运算符
this.next();
在控制器中,您无法直接执行此操作。
但我有一个解决方案:)
component.triggerNextFun();
答案 1 :(得分:0)
您也可以尝试这种方式
JS控制器:
({
doInit : function(component, event, helper){
var action = component.get("c.getBeforeAWBDetails");
action.setParams({
"CaseId" : component.get("v.recordId")
});
console.log("caseId :" + component.get("v.recordId"));
action.setCallback(this, function(response) {
var state = response.getState();
if(component.isValid() && state == "SUCCESS"){
component.set("v.BeforeAWB", response.getReturnValue());
}
});
$A.enqueueAction(action);
},
closeModal : function(component, event, helper) {
$A.get('e.force:refreshView').fire();
var reInit = component.get("c.doInit");
// use this and extend the values you need to get from "doInit" method
$A.enqueueAction(reInit);
}
})