将参数传递给异步函数Aurelia

时间:2016-04-13 15:57:59

标签: typescript async-await aurelia

我有异步函数,它接受参数。 当我在click.tirgger =“myFunc(param1,param2)”中调用它时,或者将其传递给子组件,因为回调参数不存在。 当我删除异步关键字时,一切都开始工作。

 <button type="button" click.trigger="getPlayersData(currentPage)" class="btn btn-info col-lg-1">Show</button>

async getPlayersData(currentPage: number){
  var data = await this.reportService.getPlayersData(start, end,  currentPage, this.rowCount); 
  //do something 
}

async getPlayersData(startDate, endDate, page, rowCount): Promise<ReportModel> {
    try {          
        var response = await this.http.fetch('api/reportController/getPlayerBusinessReport?startDate=' + startDate + '&endDate=' + endDate + '&page=' + page + '&rowCount=' + rowCount, {
            method: 'get'
        });
        var data = await response.json();

       // form ReportModel object
       //report = ReportModel(data)

        return Promise.resolve(report);
    }
    catch (ex) {
        //error handling
    }

}

我怎么能解决这个问题?

0 个答案:

没有答案