How to bind dynamic values to the dropdown using ionic?


Hi im just trying to bind the dynamic values to the dropdown but i confused how to bind it .

here is my json data

    "Name": "data1",  
    "sno": 3

    "Name": "data2",  
    "sno": 4
    "Name": "data3",  
    "sno": 5

here im calling my dynamic data using providers

var url1 ='';
return this.http.get(url1).map(result=>{
  return result.json();

after that im calling this in a page by calling it in the constructor and then using ngOnIt im initializing it

selectedValue: number;
  optionsList: Array<{ value: number, text: string}> = [];

the after declaring in the constructor


    this.optionsList = this.serv.dropDown().subscribe( response =>{



    <ion-option *ngFor="let item of optionsList" value="{{item.value}}">{{item.text}}</ion-option>

but im getting error as subscription is not assignable to the type and how to get the selected value and text?


Because you bothered to give things types, you got an error message that guides you to what is wrong. The return value of subscribe is a subscription; what you probably want to do instead of assigning it to optionsList is to assign inside the subscription:

this.serv.dropDown().subscribe(opts => this.optionsList = opts);