我使用表将数据库发布到服务器。我想在另一个单元格中获得表的3个单元格的总输出(自动)。用户在前3个单元格中输入数据,第3个单元格应为这2个输入的总和,这是在各个单元格中提供数据而不是通过单击按钮或提交按钮完成的操作
我尝试了带有标签的标签,但显示错误
<div>
<form class="form-inline" (ngSubmit)="onSubmit(f)" #f="ngForm">
<table class="table">
<tr>
<td>RRU Count 2G</td>
<td><input type="number" name="RRUCount2G" ngModel></td>
<td>RRU Count 3G4G</td>
<td><input type="number" name="RRUCount3G4G" ngModel></td>
<td>TDD RRU Count</td>
<td><input type="number" name="TDDRRUCount" ngModel></td>
</tr>
<tr>
<td> MIMO RRU Count</td>
<td><input type="number" name="MIMORRUCount" ngModel></td>
<td>Total RRU Count</td>
<td oninput="TotalRRUCount.value=
parseInt(RRUCount2G.value)+parseInt(RRUCount3G4G.value)" ></td>
<output name="TotalRRUCount"></output>
</tr>
</table>
</form>
</div>
import { Component, OnInit } from '@angular/core';
import { NgForm } from '@angular/forms';
import { VILKerala } from '../assetmodel';
import { ApiService } from '../api.service';
import { Injectable } from '@angular/core';
import { HttpEvent, HttpRequest, HttpHandler,HttpInterceptor, HttpErrorResponse } from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { retry, catchError } from 'rxjs/operators';
import { ErrorHandler } from '@angular/core';
@Component({
selector: 'app-sitecreate',
templateUrl: './sitecreate.component.html',
styleUrls: ['./sitecreate.component.css']
})
export class SitecreateComponent implements OnInit {}
constructor(private apiService:ApiService) { }
ngOnInit() {
}
onSubmit(form:NgForm) {
const site: VILKerala={
RRUCount2G:form.value.RRUCount2G,
RRUCount3G4G:form.value.RRUCount3G4G,
TDDRRUCount:form.value.TDDRRUCount,
MIMORRUCount:form.value.MIMORRUCount,
TotalRRUCount:form.value.TotalRRUCount,}
this.apiService.sendSite(site).subscribe((response)=>{
console.log(response);
alert('Successfully created')
form.reset()
});
console.log(JSON.stringify(site));
}
}