数据不与具有角度的离子中的前视图绑定

时间:2018-03-21 13:13:20

标签: angular ionic-framework

我需要在home.html的UserName和Email前面获取数据。但现在我变得如下了 enter image description here

home.ts

ngOnInit() {
    this.resetForm();
    this.userClaims= this.userService.userClaims;
  }

home.html的

<div class="card-content">
        <span>Username :{{userClaims.Name}}</span>
        <br>
        <span>Email : {{userClaims}}</span>
        <br>     
      </div>

我在控制台中获取数据如下图所示 enter image description here 应用-data.service.ts

sendMobileNo(mobno) {
        var data = "MobileNo=" + mobno;
        var reqHeader = new HttpHeaders({ 'Content-Type': 'application/json'});
       var url=this.uihelper.CallWebAPIUrlNew("/Tenant/GetTenantsByMobile")+"?"+data;
        return this.http.get(url).map((response: Response) => {
            var data = response.json();
            this.userClaims(data);
        });

这是初始组件,我通过发送 mobno 作为参数来调用服务 的 register.ts

OnSubmit(mobno){
    this.regService.sendMobileNo(mobno).subscribe((data : any)=>{
      this.navCtrl.push(HomePage);
    },
   (err : HttpErrorResponse)=>{
     this.isLoginError = true;
   });

register.html

<form id="register-form3" #registrationForm="ngForm" (ngSubmit)="OnSubmit(MobileNo.value)">
    <ion-list id="register-list11">
      <ion-item id="register-input8">
        <ion-label>
          Phone Number
        </ion-label>
        <ion-input type="number" #MobileNo ngModel name="MobileNo"placeholder=""></ion-input>
      </ion-item>
    </ion-list>
    <button id="register-button7" ion-button color="positive" block on-click="goToBankList()">
      Search Bank
    </button>
  </form>

任何人都可以帮我修正所需的..

1 个答案:

答案 0 :(得分:0)

将您的数据分配给userClaims,而不是像

那样传递数据
this.userClaims = data[0];