如何从离子3

时间:2017-10-29 15:00:00

标签: arrays object ionic-framework

我想返回此数组中的每个元素并将其设置为ionic 3 ts文件中的字符串变量:0:{Name:" s",DateOfBirth:" s",地址:电话:" s"} 0:{姓名:" s",DateOfBirth:" s",地址:" s",电话:" s"} proto :Objectlength:1 proto :数组(0)

我的离子3代码是:

   public items : any =[];
   PatientName:string;

   public Name:string;
   public DateOfBirth:string;
   public Adress:string;
   public Telephone:string;


   public name:string;
   public dateOfBirth:string;
   public adress:string;
   public telephone:string;


  constructor(public http:Http,public navCtrl: NavController, public 
  navParams: NavParams) {
  this.PatientName=navParams.get('Username');
    }


    load(){




    this.http.get('http://localhost:10080/testdb/PatientProfile.php?
    Patientname='+this.PatientName)
    .map(res => res.json())
    .subscribe(data => 
    {
       this.items = data; 

        this.DateOfBirth=this.items.DateOfBirth;
        this.Adress=this.items.Adress;
        this.Telephone=this.items.Telephone;
        console.log(data);        
    });









    }

ionViewDidLoad() {

this.PatientName=this.navParams.get('Username');
console.log(this.PatientName);
console.log('ionViewDidLoad PatientInfoPage');
this.load();

}

这是.html文件"

    <ion-item>
    <ion-label floating color="primary">Name</ion-label>


    <ion-input 
       type="text" 


       [(ngModel)]="Name" value="{{name}}"></ion-input>



      </ion-item>

      <ion-item>
      <ion-label floating color="primary">Date Of Birth</ion-label>


    <ion-input 
       type="text" 


       [(ngModel)]="DateOfBirth" value="{{dateOfBirth}}"></ion-input>

    </ion-item>

    <ion-item> 
    <ion-label floating color="primary">Adress</ion-label>


    <ion-input 
       type="text" 


       [(ngModel)]="Adress" value="{{adress}}"></ion-input>

      </ion-item>
      <ion-item>
       <ion-label floating color="primary">Telephone Number</ion-label>


    <ion-input 
       type="text" 


       [(ngModel)]="Telephone" value="{{telephone}}"></ion-input>


    </ion-item>

0 个答案:

没有答案