2017-02-27 2 views
-1

Können Sie mir bitte helfen, dieses Problem zu lösen:Angular 2 und Firebase werfen ThenableReference Ausnahme auf Formular

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. 

Mein Code in Service:

addBusiness(newBusiness): Promise<any>{ 
    return this.businesses.push(newBusiness); 
    } 

und Codes in der Komponente:

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

Hey, hast du es geschafft, das zu lösen? Ich habe das gleiche Problem ? – bobin56

Antwort

-2

Diese Arbeit für mich

addBusiness (newBusiness): Versprechen & ltany & gt {

this.businesses.push(newBusiness); 
return 

}

+0

Bitte erläutern Sie Ihre Antwort etwas genauer –

1
  1. machen Ihre addBusiness Methode Rückkehr firebase.Thenable statt Versprechen
  2. erstellen Promise Objekt

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