I am attempting to use Resolve in my application. However, with my current code it is rendering a blank page. What is wrong with my approach?
My route:
.state('tab.recipe', {
url: '/recipes/:recipeId',
views: {
'recipes-tab': {
templateUrl: 'js/modules/recipes/partials/recipe.html',
controller: 'RecipeController',
resolve: {
recipe : ['RecipesService', '$stateParams', '$q', function(RecipesService, $stateParams, $q) {
var defer = $q.defer();
RecipesService.getRecipe(0).success(function(data) {
defer.resolve(data);
});
return defer.promise;
}]
}
}
}
})
And the service
RecipesModule.service('RecipesService', ['$rootScope', '$http',
function($rootScope, $http) {
var recipes = [
{ id : 0, title : 'A burger', image : 'img/1.png'}
];
this.getRecipe = function(id) {
return recipes[id];
}
}
]);