【问题标题】:Reuse screen to edit重复使用屏幕进行编辑
【发布时间】:2019-03-03 23:53:49
【问题描述】:

我有一个带有日期字段的屏幕和一些带有框的屏幕,我需要填充它们以重新美化屏幕以进行编辑,屏幕用于注册和编辑,但是我无法将数据传递到组合框字段。银行返回的数据就是期权的id。

页面代码:

    <ion-grid  *ngFor="let editar of lista_despesa_ed">

        <ion-row>
          <ion-col col-6 class="sem-espaco">
            <ion-item>
              <ion-label floating>Data</ion-label>
              <ion-datetime class="input-color" displayFormat="DD MM YYYY" pickerFormat="DD MM YYYY" [(ngModel)]="data"></ion-datetime>
            </ion-item>
            <h6 *ngIf="errorData" class="error"> {{messageData}}</h6>
          </ion-col>
        </ion-row>

        <ion-row>
          <ion-col col-12 class="sem-espaco">
            <ion-list>
              <ion-item>
                <ion-label floating>Centro de Custo</ion-label>
                <ion-select (ionChange)="resetCusto()" [(ngModel)]="custo" class="input-color">
                  <ion-option *ngFor="let custo of lista_centroCusto" [selected]="editar.IDCentroCusto" value="{{custo.Chave}}">{{custo.Valor}}
                  </ion-option> //The error occurs here
                </ion-select>
              </ion-item>
              <h6 *ngIf="errorCusto" class="error"> {{messageCusto}}</h6>
            </ion-list>
          </ion-col>
        </ion-row>

打字稿文件:

  ionViewDidEnter() {
    if (this.global.acao === "I") {
      this.carregaCB();
    } else if (this.global.acao === "E") {
      this.carregaCB();
      this.AprovacaoProvider.listaDetalhe().then((data) => {
        this.lista_despesa_ed = data;
      })
    }
  }

【问题讨论】:

  • 欢迎来到 StackOverflow!由于您的声誉高于 15,您可以对问题和答案进行投票。随时查看 what upvoting is当您遇到您认为特别有用的问题、答案或评论时,请投票! :)

标签: angular typescript ionic-framework ionic2 ionic3


【解决方案1】:

由于您在该组合框中使用[(ngModel)] 并且custo 是绑定到它的组件的属性,因此您只需将已选择的选项的值分配给您的custo 属性组件文件:

this.custo = editar.IDCentroCusto; // Not sure if this is the right property

然后在视图中:

<ion-select [(ngModel)]="custo" class="input-color">
    <ion-option *ngFor="let custo of lista_centroCusto" [value]="custo.Chave">{{custo.Valor}}</ion-option>
</ion-select>

请注意,我还建议对value 使用属性绑定(而不是字符串插值),如下所示:[value]="custo.Chave"

【讨论】:

    猜你喜欢
    • 2021-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-06
    • 2017-03-18
    • 2017-01-10
    • 1970-01-01
    相关资源
    最近更新 更多