我創建了一個Modal
頁面,在這裏我想告訴pre-populated
data
用戶,每當用戶edits
data
它必須綁定到我的本地collectDataInModalPage_afterEdit
形式。如何預填充ngModel結合
演示這裏:https://stackblitz.com/edit/ionic-jse3zv?file=pages%2Fhome%2Fhome.ts
問題:[(ngModel)]="collectDataInModalPage_afterEdit"
< =這個ngModel
離開form
空白,因爲它被設置爲空在這裏begining
它
collectDataInModalPage_afterEdit = {
"first_name":"",
"last_name":"",
"mobile_number":""
};
我拿出[(ngModel)]
爲mobile_number
字段填充,請參閱演示
問:我想這data
=>userDataBeforeEdit
到pre-populate
形式,並希望收集data
這一=>collectDataInModalPage_afterEdit
演示這裏:https://stackblitz.com/edit/ionic-jse3zv?file=pages%2Fhome%2Fhome.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
userDataBeforeEdit = {
"first_name":"John",
"last_name":"Doe",
"mobile_number":"98869934445",
};
collectDataInModalPage_afterEdit = { "first_name":"","last_name":"","mobile_number":""};
constructor(public navCtrl: NavController) {
}
}
HTML
<ion-item>
<ion-label floating>Name</ion-label>
<ion-input type="text" value="{{userDataBeforeEdit.first_name}}" [(ngModel)]="collectDataInModalPage_afterEdit.first_name"></ion-input>
</ion-item>
<ion-item>
<ion-label floating>Last Name</ion-label>
<ion-input type="text" value="userDetails" [(ngModel)]="collectDataInModalPage_afterEdit.last_name"></ion-input>
</ion-item>
<ion-item>
<ion-label floating>Phone Number</ion-label>
<ion-input type="text" value="{{userDataBeforeEdit.mobile_number}}"></ion-input>
</ion-item>
請幫助我感謝在Adavance !!!!
我休假了,所以遲到了 – EaB