小编Hen*_*rix的帖子

Angular 等待承诺解决后再继续

我的以下代码是项目验证部分的一部分。这段代码的目的是检查引用表中是否存在某个值。如果存在,则可以继续。如果不是,则抛出错误并停止用户。

saveChanges() {
    //blah blah
    if (needTovalidate){
    passedCheck = false;
    this.validationService.checkExistence(value)
    .then((exist: boolean) => {
      passedCheck = exist;
      console.log("INSIDE: " + exist);

    });
    console.log("OUTSIDE: " + passedCheck);

    if(passedCheck) {
        //Rest of code
    } else {
        //Throw error msg
    }
}


public async checkExistence(value: string): Promise<boolean>{
  var exist = false;
  return this.getRefData().then((rec: dataModel[]) => {
    return rec.some(el => {
      return el.col1 === value;
    });
  });
}

private async getRefData() {
  return await this.configurationService.retrieveTableData().toPromise(); 
}
Run Code Online (Sandbox Code Playgroud)

预期日志:

INSIDE: true
OUTSIDE:true
Run Code Online (Sandbox Code Playgroud)

实际日志:

OUTSIDE: false …
Run Code Online (Sandbox Code Playgroud)

promise angular

6
推荐指数
1
解决办法
4万
查看次数

Ag-Grid:编译错误 [ts] 类型“IRowModel”上不存在属性“rowsToDisplay”

我在我的 Angular 项目中使用 Ag-grid。

下面是代码:

var displayModel = this.gridOptions.api.getModel();
var rowNode = displayModel.rowsToDisplay[params.rowIndex];
Run Code Online (Sandbox Code Playgroud)

错误被抛出rowsToDisplay

TS2339: Property 'rowsToDisplay' does not exist on type 'IRowModel'.
Run Code Online (Sandbox Code Playgroud)

我能够成功运行它,但无法编译。

我错过了导入任何东西吗?我正在使用 v17 的 ag-grid 社区版本。

分享一些背景

我使用 rowsToDisplay,因为我想在排序后按索引获取行数据。原版gridOptions.api.getRowNode对我不起作用,因为它没有考虑sorting哪个会重新排列索引号...如果我错了,请纠正我。

ag-grid

5
推荐指数
1
解决办法
2737
查看次数

C#-在Main函数中使用Async

根据这篇文章,票数最高的答案表明我们可以直接在main中使用async。还是我误会了?

无法在控制台应用程序的“主要”方法上指定“异步”修饰符

我的主班:

public class Program
{
    public static async Task Main(string[] args)
    {
        ApproveEvents ap = new ApproveEvents();
        List<MyModel> result = new List<MyModel>();
        result = await ap.ApproveAsync();
        if (result.count > 0)
        {
            //do something here
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

和,

public class ApproveEvents
{
    public async Task<List<MyModel>> ApproveAsync()
    {
        //blah blah
    }
}
Run Code Online (Sandbox Code Playgroud)

Visual Studio 2017抱怨no Main method for an entry point

我该如何解决?

c# visual-studio

2
推荐指数
1
解决办法
170
查看次数

Pandas 将 Int64(大写)转换为 int64

我得到一个结果 DataFrame,其列类型为Int64.

我怎样才能将它转换为int64

下面的代码不起作用。

print(region_ids.mycolumn.dtypes) 
region_ids['mycolumn'].astype(int64)    
print(region_ids.mycolumn.dtypes)
Run Code Online (Sandbox Code Playgroud)

实际结果:

Int64
Int64
Run Code Online (Sandbox Code Playgroud)

预期结果:

Int64
int64
Run Code Online (Sandbox Code Playgroud)

python numpy dataframe

1
推荐指数
1
解决办法
2503
查看次数

C#Automapper,无法隐式转换为Task返回类型

我知道它看起来很简单,但我花了很多时间在这上面.

不知怎的,我无法成功返回列表...

public Task<List<MyViewModel>> getGoodElections(long actionId)
{
    var elections = _DBsource.ElectionTable.Where(e => e.ActionId == actionId && e.Status == "OK").ToListAsync();
    List< MyViewModel > list = Mapper.Map<List<MyViewModel>>(elections);
    return list;

}
Run Code Online (Sandbox Code Playgroud)

在"返回列表;",它给了我错误:

无法隐式转换System.Collections.Generic.List<MyViewModel>System.Threading.Tasks.Task<System.Collections.Generic.List<MyViewModel>>

有任何想法吗?

c# automapper

0
推荐指数
1
解决办法
557
查看次数

标签 统计

c# ×2

ag-grid ×1

angular ×1

automapper ×1

dataframe ×1

numpy ×1

promise ×1

python ×1

visual-studio ×1