How to convert Observable to array[]

后端 未结 4 1780
暗喜
暗喜 2020-12-05 04:13

I have following method in typescript, I need to bind to angular grid

CountryService

GetCountries()  {
  return this.http.get(`http         


        
4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 04:50

    //Component. home.ts :

      contacts:IContacts[];
    
    
    ionViewDidLoad() {
    this.rest.getContacts()
    .subscribe( res=> this.contacts= res as IContacts[]) ;
    

    // reorderArray. accepts only Arrays

        Reorder(indexes){
      reorderArray(this.contacts, indexes)
    }
    

    // Service . res.ts

    getContacts(): Observable {
    return this.http.get(this.apiUrl+"?results=5")
    

    And it works fine

提交回复
热议问题