Angular 当我按下“关闭”或该按钮失去焦点时,模式正在(视觉上)更改mi网格信息
当我按下“关闭”或更改焦点时,模式正在(视觉上)更改网格信息。 我已经尝试过创建一个临时变量,但仍然不起作用。我不知道怎么解决这个问题 我不想在编辑某些内容并按“保存”显示时丢失信息。我这样做是为了不必在每次编辑时调用我的web服务 modal.page.tsAngular 当我按下“关闭”或该按钮失去焦点时,模式正在(视觉上)更改mi网格信息,angular,typescript,ionic-framework,Angular,Typescript,Ionic Framework,当我按下“关闭”或更改焦点时,模式正在(视觉上)更改网格信息。 我已经尝试过创建一个临时变量,但仍然不起作用。我不知道怎么解决这个问题 我不想在编辑某些内容并按“保存”显示时丢失信息。我这样做是为了不必在每次编辑时调用我的web服务 modal.page.ts import { Component, OnInit, Input, SkipSelf } from '@angular/core'; import { ModalController } from '@ionic/angular'; i
import { Component, OnInit, Input, SkipSelf } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { ProductoDetalle } from '../models/productoDetalle.model';
import { AlertController } from '@ionic/angular';
@Component({
selector: 'app-modal',
templateUrl: './modal.page.html',
styleUrls: ['./modal.page.scss'],
})
export class ModalPage implements OnInit {
row;
arreglo = ['end_date_active', 'start_date_active', 'fecha_actualizacion', 'usuario_actualizacion'];
columnas: ProductoDetalle;
rowTemp;
constructor(public modalController: ModalController, public alertCtrl: AlertController) { }
@Input() getdata;
ngOnInit() {
// this.filtraTextbox(this.arreglo, getdata2);
this.row = this.getdata;
this.rowTemp = this.getdata;
}
async alertConfirm(row: ProductoDetalle) {
const alert = await this.alertCtrl.create({
header: 'Alerta!',
message: '¿Desea <strong>guardar</strong> los cambios?',
buttons: [
{
text: 'Cancelar',
role: 'cancel',
cssClass: 'secondary',
handler: () => {
this.rowTemp = this.row;
}
}, {
text: 'Confirmar',
handler: () => {
this.row = this.rowTemp;
this.modalController.dismiss({row});
}
}
]
});
await alert.present();
}
async closeModal() {
this.rowTemp = this.row;
await this.modalController.dismiss();
}
trackByFn(index, item) {
return index;
}
filtraTextbox(key, datarray) {
key.forEach( elemento => delete datarray[elemento] );
return datarray;
}
}
从'@angular/core'导入{Component,OnInit,Input,SkipSelf};
从'@ionic/angular'导入{ModalController};
从“../models/ProductoDetalle.model”导入{ProductoDetalle};
从'@ionic/angular'导入{AlertController};
@组成部分({
选择器:“应用程序模式”,
templateUrl:'./modal.page.html',
样式URL:['./modal.page.scss'],
})
导出类ModalPage实现OnInit{
一行
arreglo=['end_date_active'、'start_date_active'、'fecha_Realizacion'、'usuario_Realizacion'];
专栏:ProductoDetalle;
rowTemp;
构造函数(公共modalController:modalController,公共alertCtrl:AlertController){}
@输入()获取数据;
恩戈尼尼特(){
//this.filterExtBox(this.arreglo,getdata2);
this.row=this.getdata;
this.rowTemp=this.getdata;
}
异步警报确认(行:ProductODatalle){
const alert=wait this.alertCtrl.create({
标题:“Alerta!”,
信息:“?德西娅瓜达尔洛斯坎比奥斯”,
按钮:[
{
文本:“取消”,
角色:“取消”,
cssClass:“次要”,
处理程序:()=>{
this.rowTemp=this.row;
}
}, {
文本:“Confirmar”,
处理程序:()=>{
this.row=this.rowTemp;
this.modalController.discover({row});
}
}
]
});
等待警报。当前();
}
异步closeModal(){
this.rowTemp=this.row;
等待此消息。modalController.disclose();
}
trackByFn(索引,项目){
收益指数;
}
过滤框(键,数据阵列){
key.forEach(elemento=>deletedatarray[elemento]);
返回数据数组;
}
}
modal.page.html
修改产品{{rowTemp.sku}
{{col.key}}
瓜达尔
好的,您想要什么?英雄联盟我唯一能理解的是对我的英语感到抱歉。为了尽你所能帮助你,weite tou想让我们在google translator中知道什么,用你的语言写下tou想实现什么,然后翻译成英语,但现在我真的什么都不懂,甚至连代码都不懂…@MostafaHarb目前我的模式正在改变网格信息(视觉上)当我关闭模态或失去焦点时。我希望它仅在按下保存按钮时显示对网格的更改。按save将通过“this.modalController.dismise({row});”中的“async alertConfirm(row:ProductoDetalle))”方法将数据发送到另一个组件。确定,在从modal close发送的数据中,发送回包含项索引和已更改数据的对象,如果多个项返回包含要更改的项索引和数据的多个对象的数组,并且在onmodel上,然后为页面数组创建一个for循环,并在其中创建if语句来比较if array.index==从模态索引返回的数组/索引,然后将其数据设置为新返回的数据确定需要什么?英雄联盟我唯一能理解的是对我的英语感到抱歉。为了尽你所能帮助你,weite tou想让我们在google translator中知道什么,用你的语言写下tou想实现什么,然后翻译成英语,但现在我真的什么都不懂,甚至连代码都不懂…@MostafaHarb目前我的模式正在改变网格信息(视觉上)当我关闭模态或失去焦点时。我希望它仅在按下保存按钮时显示对网格的更改。按save将通过“this.modalController.dismise({row});”中的“async alertConfirm(row:ProductoDetalle))”方法将数据发送到另一个组件。确定,在从modal close发送的数据中,发送回包含项索引和已更改数据的对象,如果多个项返回包含要更改的项索引和数据的多个对象的数组,则在onModal discome promise上,然后为页面数组创建一个for循环,并在其中生成if语句以比较if array.index==模态索引/索引返回的数组,然后将其数据设置为新的返回数据