[英]Angular function that does task I can not figure out why it is this function
I have a sample code that is written in angular/node. 我有一个用angular / node编写的示例代码。 I pin pointed the function that performs a task.
我指出了执行任务的功能。 I can not figure out why..or how.
我无法弄清楚为什么......或者如何。
I was able to go through the snippets of code and pin point the record by adding a console.log() and logging out the data so I know the function i found is the correct one i just dont undestand why because in angular it is called "delete()" but in the function it is called "deleteValue()" 我能够通过代码片段和pin指向记录,添加一个console.log()并注销数据,所以我知道我找到的函数是正确的,我只是不明白为什么因为在角度它被称为“delete()”但在函数中它被称为“deleteValue()”
This is the angular as you can see the delete(row._id) is the onclick function that gets called. 这是angular,你可以看到delete(row._id)是被调用的onclick函数。
<div class="card-body">
<ngx-datatable class='material' *ngIf="row" [columnMode]="'force'"
[headerHeight]="40" [footerHeight]="40" [rowHeight]="'50'"
[limit]="500000" [rows]='perm' [scrollbarH]="true"
#table [limit]="_limit" >
<ngx-datatable-column prop="value" name="Name" [width]="130"
[sortable]="true">
<ng-template let-row="row" let-value="value" ngx-datatable-cell-template>
{{row.value}}
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column prop="qty" name="Qty" [width]="130"
[sortable]="true">
<ng-template let-row="row" let-value="value" ngx-datatable-cell-template>
{{row.qty}}
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column name="Action" [sortable]="false" [width]="75">
<ng-template let-row="row" let-value="value" ngx-datatable-cell-template>
<div class="justify-content-center align-items-center">
<span class="col-md-4">
<button class="btn btn-danger" (click)="delete(row._id)">
Delete
</button>
</span>
</div>
</ng-template>
</ngx-datatable-column>
</ngx-datatable>
</div>
This is the nodejs code: 这是nodejs代码:
valueController.deleteValue= async (req)=>{
try{
var recordType = await valueModel.deleteValue({_id: req.params.id});
console.log('Deleting record: ' + req.params.id);
return recordType;
} catch(error) {
throw error;
}
}
Thanks, 谢谢,
I was expecting the function to be called delete not deleteValue how does this work? 我期待这个函数被称为删除而不是deleteValue这是如何工作的?
(click)="delete(row._id)"
Will call a method called delete on the Angular component, we cannot see your Angular TypeScript here but the component would then normally then call an Angular service and that service would then make a http call to your node api. 将在Angular组件上调用一个名为delete的方法,我们无法在此处看到您的Angular TypeScript,但组件通常会调用Angular服务,然后该服务将对您的节点api进行http调用。
The click function on a button is not going to directly call the api. api上的点击功能不会直接调用api。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.