Использование формы в таблице, которая использует * ngFor для обновления элементов в базе данных. - PullRequest
0 голосов
/ 12 апреля 2019

Я работаю с таблицей, получая данные из ответа http.get.Данные должны быть загружены в виде формы, внутри таблицы и управляться функцией, которая должна обновляться путом.Он должен быть отправлен в виде массива с новыми данными.

Что у меня есть с моей таблицей.

app.html

<table class="table table-bordered text-center">
  <tr>
    <th class="text-center">Cuenta</th>
    <th class="text-center">MES 2018</th>
    <th class="text-center">MES 2019</th>
    <th class="text-center">Ajuste a convenir</th>
    <th class="text-center">MES 2019 Plan + Ajuste</th>
  </tr>

  <ng-container *ngFor="let centro of centroSelected">
    <ng-template [ngIf]="centro.cuc_cuc_id">
      <tr>
        <!--id="centro{centro.cuC_CUC_ID}" class="demo out collapse"-->
        <td>
          <span [innerHTML]="centro.cuc_numero"></span>
        </td>
        <!--PRE_REAL-->
        <td>
          <span class="text-center">{{centro.pre_planeado | currency}}</span>
        </td>
        <!--PRE AUTORIZADO-->
        <td>
          <span class="text-center">{{centro.pre_planeado | currency}}</span>
        </td>
        <td>
          <input type="number" value="" />
        </td>
        <td>
          <span>{{centro.pre_planaeado | currency}}</span>
        </td>
      </tr>
    </ng-template>
  </ng-container>

</table>

<button class="btn btn-primary float-right">Validate</button>

JSON, который у меня есть в моем.ts:

centroSelected = [{"cuc_cuc_id":null,"cuc_id":1004,"cuc_numero":"&nbsp;&nbsp;&nbsp;400-000-001-00","anio_anterior":null,"pre_cpe_id":null,"hijos":2,"nivel":1,"orden":"1004","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":1004,"cuc_id":1007,"cuc_numero":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;400-000-001-01","anio_anterior":null,"pre_cpe_id":null,"hijos":0,"nivel":2,"orden":"1004.1007","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":1004,"cuc_id":1008,"cuc_numero":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;400-000-001-02","anio_anterior":null,"pre_cpe_id":null,"hijos":0,"nivel":2,"orden":"1004.1008","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":null,"cuc_id":1009,"cuc_numero":"&nbsp;&nbsp;&nbsp;500-000-001-00","anio_anterior":null,"pre_cpe_id":null,"hijos":3,"nivel":1,"orden":"1009","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":1009,"cuc_id":1010,"cuc_numero":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;500-000-001-01","anio_anterior":null,"pre_cpe_id":null,"hijos":0,"nivel":2,"orden":"1009.1010","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":1009,"cuc_id":1011,"cuc_numero":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;500-000-001-02","anio_anterior":null,"pre_cpe_id":null,"hijos":0,"nivel":2,"orden":"1009.1011","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":1009,"cuc_id":1012,"cuc_numero":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;500-000-001-03","anio_anterior":null,"pre_cpe_id":null,"hijos":0,"nivel":2,"orden":"1009.1012","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":null,"cuc_id":1014,"cuc_numero":"&nbsp;&nbsp;&nbsp;600-000-000-00","anio_anterior":null,"pre_cpe_id":null,"hijos":1,"nivel":1,"orden":"1014","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":1014,"cuc_id":1015,"cuc_numero":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;600-001-000-00","anio_anterior":null,"pre_cpe_id":null,"hijos":3,"nivel":2,"orden":"1014.1015","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":1015,"cuc_id":1016,"cuc_numero":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;600-001-001-00","anio_anterior":null,"pre_cpe_id":null,"hijos":2,"nivel":3,"orden":"1014.1015.1016","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":1016,"cuc_id":1017,"cuc_numero":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;600-001-001-01","anio_anterior":null,"pre_cpe_id":null,"hijos":0,"nivel":4,"orden":"1014.1015.1016.1017","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":1016,"cuc_id":1018,"cuc_numero":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;600-001-001-02","anio_anterior":null,"pre_cpe_id":null,"hijos":0,"nivel":4,"orden":"1014.1015.1016.1018","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":1015,"cuc_id":1019,"cuc_numero":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;600-001-002-00","anio_anterior":null,"pre_cpe_id":null,"hijos":3,"nivel":3,"orden":"1014.1015.1019","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":1019,"cuc_id":1020,"cuc_numero":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;600-001-002-01","anio_anterior":null,"pre_cpe_id":null,"hijos":0,"nivel":4,"orden":"1014.1015.1019.1020","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":1019,"cuc_id":1021,"cuc_numero":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;600-001-002-02","anio_anterior":null,"pre_cpe_id":null,"hijos":0,"nivel":4,"orden":"1014.1015.1019.1021","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":1019,"cuc_id":1022,"cuc_numero":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;600-001-002-03","anio_anterior":null,"pre_cpe_id":null,"hijos":0,"nivel":4,"orden":"1014.1015.1019.1022","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":1015,"cuc_id":1026,"cuc_numero":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;600-001-003-00","anio_anterior":null,"pre_cpe_id":null,"hijos":1,"nivel":3,"orden":"1014.1015.1026","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6},{"cuc_cuc_id":1026,"cuc_id":1027,"cuc_numero":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;600-001-003-01","anio_anterior":null,"pre_cpe_id":null,"hijos":0,"nivel":4,"orden":"1014.1015.1026.1027","pre_planaeado":0.00,"proy_lineal":52.10,"proy_comercial":52.10,"proy_sugerida":52.10,"pre_autorizado":0.00,"pre_real":0.00,"pre_cco_id":6}]
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...