Hello everyone, I recently created a small AngularJS application and utilized a JSON server for my backend operations. Unfortunately, I am encountering an issue with the provider in my code. Upon running it, I am receiving errors as shown below:
Uncaught TypeError: b.module(...).info is not a function at angular-resource.min.js:6 at angular-resource.min.js:14 angular.js:12808 Error: [$injector:unpr] Unknown provider: $resourceProvider <- $resource <- menuFactory http://errors.angularjs.org/1.4.14/$injector/unpr?p0=%24resourceProvider%20%3C-%20%24resource%20%3C-%20menuFactory at at at Object.getService [as get] () at at getService () at invoke () at Object.instantiate () at Object. () at Object.invoke () at Object.enforcedReturnValue [as $get] ()
Below are the codes for my menufactory:
angular.module('confusionApp')
.constant("baseURL","http://localhost:3000/")
.service('menuFactory', ['$resource','baseURL', function($resource, baseURL) {
var promotions = [
{
_id:0,
name:'Weekend Grand Buffet',
image: 'images/buffet.png',
label:'New',
price:'19.99',
description:'Featuring mouthwatering combinations with a choice of five different salads, six enticing appetizers, six main entrees and five choicest desserts. Free flowing bubbly and soft drinks. All for just $19.99 per person ',
}
];
this.getDishes = function () {
return $resource(baseURL+"dishes/:id",null, {'update': {'method':'PUT'}});
};
this.getPromotion = function (index) {
return promotions[index];
};
}])
And here is the controller snippet:
angular.module('confusionApp')
.controller('MenuController', ['$scope', 'menuFactory', function($scope, menuFactory) {
$scope.tab = 1;
$scope.filtText = '';
$scope.showDetails = false;
$scope.showMenu = true;
$scope.message = "Loading...";
$scope.dishes = menuFactory.getDishes().query();
$scope.select = function(setTab) {
$scope.tab = setTab;
if (setTab === 2) {
$scope.filtText = "appetizer";
}
else if (setTab === 3) {
$scope.filtText = "mains";
}
else if (setTab === 4) {
$scope.filtText = "dessert";
}
else {
$scope.filtText = "";
}
};
$scope.isSelected = function (checkTab) {
return ($scope.tab === checkTab);
};
$scope.toggleDetails = function() {
$scope.showDetails = !$scope.showDetails;
};
}])
This is the routing information:
'use strict';
angular.module('confusionApp', ['ui.router', 'ngResource'])
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
// route for the home page
.state('app', {
url:'/',
views: {
'header': {
templateUrl : 'views/header.html'
},
'content': {
templateUrl : 'views/home.html',
controller : 'IndexController'
},
'footer': {
templateUrl : 'views/footer.html'
}
}
})
// route for the aboutus page
.state('app.aboutus', {
url:'aboutus',
views: {
'content@': {
templateUrl : 'views/aboutus.html',
controller : 'AboutController'
}
}
})
// route for the contactus page
.state('app.contactus', {
url:'contactus',
views: {
'content@': {
templateUrl : 'views/contactus.html',
controller : 'ContactController'
}
}
})
// route for the menu page
.state('app.menu', {
url: 'menu',
views: {
'content@': {
templateUrl : 'views/menu.html',
controller : 'MenuController'
}
}
})
// route for the dishdetail page
.state('app.dishdetails', {
url: 'menu/:id',
views: {
'content@': {
templateUrl : 'views/dishdetail.html',
controller : 'DishDetailController'
}
}
});
$urlRouterProvider.otherwise('/');
})
;
Thank you for taking the time to read through.