I am new in using Observables. So here is my code
recipesList:Recipe[];
private recipes;
constructor(private shoppingService:ShoppingListService,private http:Http){
this.getRecipesFromUrl().subscribe((data)=>{
this.recipesList=data;
console.log(this.recipesList);//printing array containing recipes
});
console.log(this.recipesList);//printing undefined
}
My problem is when i print the recipeList inside the subscribe i am getting the recipes but when i am printing outside its displaying undefined. How to save data to recipeList so that i can access it in my other methods.