简体   繁体   English

执行任务的角度函数我无法弄清楚为什么它是这个函数

[英]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.

相关问题 我似乎无法弄清楚为什么我在 console.log 在 async/await function - I can't seem to figure out why I get 'undefined' after I console.log a value after an async/await function 尝试按照示例操作,但我不知道为什么会出现错误 - Trying to follow a sample and I can't figure out why there are errors 我的简单路由无法正常工作,我不知道为什么 - My simple routing is not working and I can't figure out why 我不明白我们为什么要使用 response.on - i can't figure out why we are using response.on req.body是空的,我无法弄清楚为什么 - req.body is empty and I can't figure out why nodejs为什么我在调用lambda函数时遇到错误“6.01秒后任务超时”? - nodejs Why am I getting an error “Task timed out after 6.01 seconds” when invoking my lambda function? 使用 axios/cheerio 制作网页抓取工具; 无法弄清楚其余的功能 - Making a webpage scraper using axios/cheerio; can't figure out the rest of the function 不知道如何解决这个问题:“Uncaught TypeError (webcam.snap is not a function)” &lt;— javascript - Can't figure out how to fix this: “Uncaught TypeError (webcam.snap is not a function)” <— javascript 我不知道为什么会出现 ReferenceError: fileUploaded is not defined - I can't figure out why I'm getting a ReferenceError: fileUploaded is not defined 无法弄清楚为什么找不到角形链接 - Cannot figure out why the link is not being found in angular
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM