I am not able to get my post method and my drop down also not going back means if i select one language the drop down should go up and i am getting errors in post method


#1

home.ts file:

import { Component } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;

import { Rest } from ‘…/…/providers/network/rest’;
import { Logger } from ‘…/…/providers/logger/logger’;
import { ProductListPage } from ‘…/product-list/product-list’;

@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage {

languageShow: boolean = true;
languageHide: boolean = false;
selectedLanguage: number = 1;

mySlideOptions = {
initialSlide: 1,
loop: true,
autoplay: 1500,
pager: true
};

languages =[
{id: 1, name: ‘हिंदी’},
{id: 2, name: ‘తెలుగు’},
{id: 3, name: ‘ಕನ್ನಡ’}
];

contructor() {

}

doSomething(language)
{

 // do something with the language here
 console.log("invoking language.id();");
 console.log(this.selectedLanguage);
 this.toggleLanguages();

}

// this is for toggling your languages dropdown
toggleLanguages(){

this.languageShow = !this.languageShow;
this.languageHide = !this.languageHide;

}

productCategorieArray = [];

bannersImage = [];

languageArray = [];

offersArray=[];

kmart =‘categories’;

constructor(public navCtrl: NavController,
public rest: Rest,
public logger: Logger) {

}
ionViewDidLoad() {

this.rest.get('/getBanners')
.subscribe((result)=>{
    this.logger.debug("checking getBanners"+JSON.stringify(result));
    if(result.status == '1'){
      this.logger.info("success of get banners");
      this.bannersImage = result.data;
      this.languageArray.push(result.data);
    }
    else{
      this.logger.info("error of getBanners");
    }
})

  doSomething(language)(){

let languageObj = {
  language_id: this.value.language
}


this.logger.debug("cheking languageObj " + JSON.stringify(languageObj));

this.rest.post('/language',languageObj)
.subscribe((result)=>{
  this.logger.debug("checking data of success " +JSON.stringify(result));
  if(result.status == '1'){
    this.navCtrl.push(HomePage,{});
  }
  else{
    this.logger.info("error");
  }
});

}

home.html file:

<ion-title>
   <img src="assets/images/home/KmartText.png">
</ion-title>
<ion-buttons end>
    <button ion-button icon-only>
        <ion-icon name="search"></ion-icon>
    </button>
    <button ion-button icon-only>
        <ion-icon name="cart"></ion-icon>
    </button>    
</ion-buttons>

<ion-menu [content]=“mycontent”>




Gmail

<ion-content>
  <ion-list>
    <ion-item (click)="toggleLanguages()">
      Languages
      <ion-icon name="add" item-right *ngIf="languageShow"></ion-icon>
      <ion-icon name="remove" item-right *ngIf="languageHide"></ion-icon>
    </ion-item>
    <div *ngIf="languageHide">

      <!-- All radio's in a radio group -->

      <ion-list radio-group [(ngModel)]="selectedLanguage">
        <ion-item *ngFor="let language of languages" (click)="doSomething(language)">
          <ion-label>{{language.name}}</ion-label>
          <ion-radio item-left [value]="language.id"></ion-radio> 
        </ion-item>
      </ion-list>

    </div>

    <ion-item>
        <ion-icon name="home" item-left></ion-icon>
          My Account
     </ion-item>

     <ion-item>
        <ion-icon name="clipboard" item-left></ion-icon>
          Orders
     </ion-item>

     <ion-item>
       <ion-icon name="alert" item-left></ion-icon>
         Notification
     </ion-item>

     <ion-item>
        <ion-icon name="cart" item-left></ion-icon>
        My Cart
     </ion-item>
  </ion-list>