【发布时间】:2021-10-15 09:49:36
【问题描述】:
好的,所以这似乎有很多问题。我一直把头撞在桌子上试图弄清楚这一点。举个例子:
<ul>
<li>Number: <span id="Number">123</span></li>
</ul>
我想在 id 为“Number”的跨度和数据库之间创建一个异步链接。是否可以让用户单击元素,然后可以更改输入,然后在 Enter/Return 或取消焦点时将更新的值发送到数据库?这只是一个小型的个人项目,我想为此添加一点独特性。所以任何帮助都会很棒!
**更新
所以现在我几乎把它放在了需要的地方。但是apiCall() 函数不会使用显示数据的插值方法调用。关于如何解决这个问题的任何想法?下面是代码和错误:
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Expense</th>
<th scope="col">Amount</th>
</tr>
</thead>
<tbody>
<ng-container *ngFor="let exp of expenses">
<tr>
<th scope="row"><input type="text" class="formless" name="{{exp.expense}}" placeholder="{{exp.expense}}" (focusout)="apiCall({{exp.id}}, {{exp.expense}})"></th>
<td><input type="text" class="formless" placeholder="{{exp.price}}"></td>
</tr>
</ng-container>
</tbody>
</table>
错误:
error NG5002: Parser Error: Unexpected
token {, expected identifier, keyword, or
string at column 10 in [apiCall({{exp.id}},
{{exp.expense}})] in
<path>\budget-app\src\app\home\home.component.html@29:137
【问题讨论】:
标签: javascript html angular typescript asynchronous