2017-02-25 4 views
0

ここで私は1として店舗IDを渡すつもりだと0.Hereは= '1' STORE_IDはバンガロールとSTORE_ID = '0' ハイデラバードなど..ここ名前をポップオーバーに表示する方法は?

は私のhtmlコードです:

home.ts

presentPopover(myEvent) { 
    let popover = this.popoverCtrl.create(Popoverpage); 
    popover.present({ 
    ev: myEvent 
    }); 
} 

home.html

<ion-header> 

    <button ion-button icon-only (click)="presentPopover($event)" > 
    Choose City 
    <ion-label>{{cityname}}</ion-label> 
    <ion-icon name="arrow-dropdown" item-right></ion-icon> 
    </button> 

</ion-header> 

ここで「bengaluru」をクリックすると、popoverにその名前を表示し、「hyderabad」と同じ名前を表示する必要があることを意味します。

popoverpage.ts

@Component({ 
    template: ` 
     <ion-list> 
      <button ion-item (click)="store()">Bengaluru</button> 
      <button ion-item (click)="fun()">Hyderabad</button> 
     </ion-list> 
     ` 
}) 

export class Popoverpage{ 
    store_id 
    cityname 


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

    store() { 
     let storeObj={ 
      store_id: '1' 
     } 

     this.logger.debug("checking the " +JSON.stringify(storeObj)); 

     this.rest.post('/store',storeObj) 
      .subscribe(result => { 
       this.logger.debug("checking the data "+JSON.stringify(result)); 
       if(result.status == '1'){ 
        this.logger.info("success callback"); 
        this.cityname="Bengaluru"; 

        //this.navCtrl.pop(); 
        this.viewCtrl.dismiss(); 

       } 
       else{ 
        this.logger.info("error callback"); 
        this.viewCtrl.dismiss(); 
       } 
      }) 

    } 

    fun() { 
     let storeObj={ 
      store_id: '0' 
     } 

     this.logger.debug("checking the " +JSON.stringify(storeObj)); 

     this.rest.post('/store',storeObj) 
      .subscribe(result => { 
       this.logger.debug("checking the data "+JSON.stringify(result)); 
       if(result.status == '1'){ 
        this.logger.debug("success callback"); 
        this.cityname="Hyderabad"; 
        //this.navCtrl.pop(); 
        this.viewCtrl.dismiss(); 
       } 
       else{ 
        this.logger.debug("error callback"); 
        this.viewCtrl.dismiss(); 
       } 
      }) 

    } 

} 

すべてのボディはこれに返信してください知っていれば...

+0

問題点を教えてください。 –

+0

問題をクリックして都市を選択すると、そのドロップダウンでドロップダウンが表示されます。ベンガルールまたはハイデラバードをクリックするとその名前が表示されます。 – balu

+0

は都市を選択するという意味で、 – balu

答えて

0

私は、ボタンのクリックメソッド「ストア」と「楽しい」という名前の理由はわからないんだけど、キープクリックハンドラメソッドには常に文字列を渡すことができます。おそらくこのようなもの:

<button ion-item (click)="clicked('bangaluru')">Bengaluru</button> 
<button ion-item (click)="clicked('hyderabad')">Hyderabad</button> 

clicked (e) { 
    console.log('clicked ' + JSON.stringify(e)); 
    this.currentCity = e; 
} 

ここにはplunkr demoがあります。

関連する問題