如何在用户登录时显示和编辑ionic 3中的特定(选定)数据?

时间:2019-06-13 02:44:38

标签: laravel ionic-framework ionic3 laragon

我不知道如何在用户登录时以离子形式显示数据。

基于我的尝试,我在ionViewWillEnter中称为API。 controller.php中的API代码可以称为数据。我只是在离子部分不知道。

profle.ts

ionViewWillEnter(){
    this.authService.getAllClinic()
    .then(data => {
      this.clinic1 = data;
      this.allClinic = this.clinic1.clinic_listemailtelno;
      console.log(this.allClinic);
    });

          const data = this.navParams.get('data');
          // console.log(data);

            this.usersClinic.email = data.email;
            this.usersClinic.telno = data.telno;
            this.clinic_regno = data.clinic_regno;
            this.clinic_name = data.clinic_name;
            this.site = data.site;
            this.clinic_address = data.clinic_address;

  }

下面是我想要显示的内容。 profile.html

<ion-list>
 <form #f="ngForm" (ngSubmit)="onSubmit(f)" class="list-form">
        <ion-item>
        <ion-label stacked>Clinic Email</ion-label>
        <ion-input type="text" name="usersClinic.email" [(ngModel)]="usersClinic.email">{{usersClinic.email}}</ion-input>
        </ion-item>

        <ion-item>
        <ion-label stacked>Telephone no.</ion-label>
        <ion-input type="text" name="usersClinic.telno" [(ngModel)]="usersClinic.telno">{{usersClinic.telno}}</ion-input>
        </ion-item>

        <button ion-button color="light" class="transparent-button" [disabled]="!f.valid" text-center round>
          Edit
        </button>
      </form>
      <ion-item>
        <p>Clinic Registration no</p>
        {{clinic_regno}}
      </ion-item>
      <ion-item>
          <p>Clinic Name</p>
          {{clinic_name}}
      </ion-item> 
      <ion-item>
          <p>Clinic Site</p>
          {{site}}
      </ion-item>
      <ion-item>
          <!-- <p>Clinic Address</p>  -->
          <ion-label primary>Clinic Address</ion-label>
           <!-- <ion-textarea>{{clinic_address}}</ion-textarea> -->
           <ion-textarea rows="6" disabled [value]="clinic_address" ></ion-textarea>
      </ion-item>
</ion-list>

下面是我在API中的代码 controller.php

下面的代码成功基于另一个表调用了概要文件数据。 哪些电子邮件和电话号码来自表用户,其他电子邮件和电话号码来自表诊所。

public function allClinic(){
        $allClinic = User::where('status',2)->get();

      foreach($allClinic as $allClinicarr){
            $count = RegisterClinic::where('uid', $allClinicarr->id)->count();
            // dd($count);
            if($count!=0)
            {
                $clinicData = RegisterClinic::where('uid', $allClinicarr->id)->get();

              foreach($clinicData as $clinicDataarr){
                    $clinicData1 = RegisterClinic::where('clinic_id', $clinicDataarr->clinic_id)->first();

                 $ListArr[] = array(
                    "email" =>$allClinicarr->email,
                    "telno" =>$allClinicarr->telno,
                    "clinic_regno" =>$clinicData1->clinic_regno,
                    "clinic_name"=>$clinicData1->clinic_name,
                    "site"=>$clinicData1->site,
                    "clinic_address"=>$clinicData1->clinic_address.', '.$clinicData1->zip.', '.$clinicData1->city.', '.$clinicData1->state.'. ');
                }
                //~~
                $msg = $ListArr;
                $datamsg = response()->json([
                            'clinic_list'.'emailtelno' => $msg
                ]);
                return $datamsg->content();
            }
            else{

                $datamsg = response()->json([
                    'error' => array("text"=>"No clinic data.")
                ]);
                return $datamsg->content();
            }

        }

        $msg = $ListArr;
            $datamsg = response()->json([
                        'clinic_list'.'emailtelno' => $msg
            ]);
            return $datamsg->content();
    }

0 个答案:

没有答案