Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何识别ag网格中的每个按键事件_Angular_Typescript_Ag Grid_Ag Grid Angular - Fatal编程技术网

Angular 如何识别ag网格中的每个按键事件

Angular 如何识别ag网格中的每个按键事件,angular,typescript,ag-grid,ag-grid-angular,Angular,Typescript,Ag Grid,Ag Grid Angular,当我在文本字段中键入字母A时,我想将该字符发送到键入脚本 仅供参考, 我的目标是,当我按键盘上的键时,我想发送每个字符以键入脚本。您可以尝试使用以下代码: app.component.html <input type="text" (keyup)="getLastCharacter($event)"> <input type="text" (keyup)="getLastCharacter($event)"> 此函数将始终返回您在文本输入中添加的最后一个字符,您可以在

当我在文本字段中键入字母A时,我想将该字符发送到键入脚本

仅供参考,
我的目标是,当我按键盘上的键时,我想发送每个字符以键入脚本。您可以尝试使用以下代码:

app.component.html

<input type="text" (keyup)="getLastCharacter($event)">
<input type="text" (keyup)="getLastCharacter($event)">
此函数将始终返回您在文本输入中添加的最后一个字符,您可以在TS中执行任何操作

如果你想发送整个字符串,你可以这样做

app.component.html

<input type="text" (keyup)="getLastCharacter($event)">
<input type="text" (keyup)="getLastCharacter($event)">
工作实例

你可以这样使用

<ag-grid-angular 
    style="width: 500px; height: 150px;" 
    class="ag-theme-balham"
    [rowData]="rowData" 
    [columnDefs]="columnDefs"
    (cellKeyPress)="onCellKeyPress($event)"
    [modules]="modules">
</ag-grid-angular>

分享你的代码谢谢亲爱的,下面提到的例子在stackBlitz中运行良好,但在我的代码中,onCellKeyPress在编辑时不启动。。是否必须使用[modules]=“modules”?[modules]=modules被称为从.ts文件`到html模板的属性绑定,您可以这样说html是ag grid模块的所有CommunityModule的一部分,通过在.ts文件中设置modules=AllCommunityModules的属性,模块的此属性值将使用angular[modules]的属性绑定传递到html=modules但它抛出错误,例如无法绑定到“module”,因为它不是您自己的模块或app.module.ts文件中“ag-grid-angular”导入ag模块的已知属性。。从“@ag grid community/angular”导入{AgGridModule}@NgModule{imports:[BrowserModule,FormsModule,AgGridModule.withComponents[],如何在不使用@ag grid community/angular的情况下调用按键事件
onCellKeyPress(e){
  console.log(e.event.key);
}