如何在不使用 ngModel 的情况下使用打字稿将变量插入离子文本区域



我正在尝试将第 4 行的 (click(="runMatrix((" 调用的方法的文本结果添加到第 7 行的离子文本区域中。 通常我会使用 ngModel,但在这种情况下我不能,因为我使用 ngModel 来保存数据。

。.html

<div *ngFor="let fromItem of importQuestions let i = index">
<ion-card>  
<ion-card-content>
<div class="question_link" (click)="openMatrix()">
{{fromItem.Question}}
</div>          
<ion-textarea auto-grow="true" id="fromItem.ID" name="{{fromItem.name}}" [(ngModel)]="fromItem.input""> </ion-textarea>
</ion-card-content>
</ion-card>
<ion-card>
<ion-card-content>
<div class="question">
{{fromItem.Question}}
</div>
<ion-select multiple="true" name="{{fromItem.name}}" [(ngModel)]="fromItem.input">
<ion-select-option *ngFor="let item of importQuestions[i].values" value="{{item.value}}">{{item.value}}</ion-select-option>
</ion-select>
</ion-card-content>
</ion-card> 
</div>

(click(="runMatrix(( 方法返回一个字符串

this.resultNumber

我没有包括该方法,因为它很大。

运行该方法后,如何将结果编号放入离子文本区域的输入文本区域?

我认为在第 4 行应该是你提到的 runMatrix(((有问题的是 openMatrix(。在第 4 行进行更改,如下所示。

// passing index no to runMatrix
<div class="question_link" (click)="openMatrix(i)">

在你的 runMatrix(( 方法中获取索引号进行更改,如下所示。

runMatrix(index) {
// your logic here 
// adding updated value to the specific index no.of importQuestions
this.importQuestions[index].input = "yourResultNumber"
}

最新更新