1
當我使用fire base作爲數據庫運行ionic3應用程序時,出現了該錯誤。無法解析RecipesService的所有參數
這裏recipe.ts的內容文件:
import {Recipe} from "../src/models/recipe";
import {Ingredient} from "../src/models/ingredient";
import {AuthService} from "./auth";
import {Http, Response} from "@angular/http";
import 'rxjs/Rx';
export class RecipesService {
constructor (private authService:AuthService,
private http:Http){}
private recipes: Recipe[] = [];
addRecipe(title: string,
description: string,
difficulty: string,
ingredients: Ingredient[]) {
this.recipes.push(new Recipe(title, description, difficulty, ingredients));
console.log(this.recipes) ;
}
getRecipes() {
return this.recipes.slice();
}
updateRecipe(index: number,
title: string,
description: string,
difficulty: string,
ingredients: Ingredient[]) {
this.recipes[index] = new Recipe(title, description, difficulty, ingredients);
}
removeRecipe(index : number) {
this.recipes.splice(index, 1);
}
storeList(token: string) {
const userId = this.authService.getActiveUser().uid;
return this.http
.put('https://fir-crud-69d01.firebaseio.com/' + userId + '/recipes.json?auth=' + token, this.recipes)
.map((response: Response) => {
return response.json();
});
}
fetchList(token : string){
const userId = this.authService.getActiveUser().uid;
return this.http.get('https://fir-crud-69d01.firebaseio.com/' + userId +'/recipes.json?auth=' + token)
.map((response: Response)=> {
return response.json();
})
.do((recipes:Recipe[])=>{
if(recipes){
this.recipes= recipes;
}else {
this.recipes= []
}
});
}
}
,並從控制檯錯誤:
vendor.js:112012 Uncaught Error: Can't resolve all parameters for RecipesService: (?, ?).
這是正常工作使用recipe.ts文件作爲服務器之前將其連接在火力
你註冊app.module的供應商陣列在此服務? –