2017-02-27 9 views
-1

を提出し、フォーム上のThenableReference例外を投げるあなたがこの問題を解決するために私を助けてくださいすることができます。サービスで角度2とFirebaseは

ERROR in /src/app/services/firebase.service.ts (33,12): Type 'ThenableReference' is not assignable to type 'Promise<any>'. 
    Property '[Symbol.toStringTag]' is missing in type 'ThenableReference'.) 

webpack: Failed to compile. 

は私のコード:

コンポーネントで
addBusiness(newBusiness): Promise<any>{ 
    return this.businesses.push(newBusiness); 
    } 

とコード:

addBusiness(
    company:string, 
    category:string, 
    years_in_business:number, 
    description:string, 
    phone:string, 
    email:string, 
    street_address:string, 
    city:string, 
    state:string, 
    zipcode:string 
){ 
    var created_at = new Date().toString(); 

    var newBusiness = { 
     company: company, 
     category: category, 
     years_in_business:years_in_business, 
     description:description, 
     phone:phone, 
     email:email, 
     street_address:street_address, 
     city:city, 
     state:state, 
     zipcode:zipcode, 
     created_at:created_at 
    } 
    this._firebaseService.addBusiness(newBusiness); 
    this.changeState('default'); 
    } 
+0

ねえ、これを解決できるの?私は同じ問題を抱えています ? – bobin56

答えて

-2

私のためのこの作品

addBusiness(newBusiness):プロミス&ltany&GT {

this.businesses.push(newBusiness); 
return 

}

+0

答えをもう少し詳しく説明してください –

1
  1. Promiseオブジェクトを作成し、あなたのaddBusinessメソッドの戻りfirebase.Thenable代わりに約束を作る

    addBusiness(newBusiness): Promise<any>{ 
        return new Promise(function(resolve, reject){ 
         this.businesses.push(newBusiness) 
          .then(x=>resolve(x), x=>reject(x)); 
        }); 
    }