Answer the question
In order to leave comments, you need to log in
unknown provider in angularjs. Why is there an error?
I'm trying to write a simple site using angularjs 1.3.15 but I can't seem to get the controller to use the service.
The structure of the application is
'use strict';
var servicesModule = angular.module('servicesModule', []);
var componentsModule = angular.module('componentsModule', []);
var controllersModule = angular.module('controllersModule', ['servicesModule', 'componentsModule']);
var appModule = angular.module('appModule', ['ngRoute', 'servicesModule', 'componentsModule']);
appModule.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/sellings', {templateUrl: 'screens/SellingsScreen/SellingScreen.html', controller: 'SellingsScreenController'}).
when('/selling/:id', {templateUrl: 'screens/SellingScreen/SellingScreen.html', controller: 'SellingScreenController'}).
when('/leasings', {templateUrl: 'screens/LeasingsScreen/LeasingsScreen.html', controller: 'LeasingsScreenController'}).
when('/leasing/:id', {templateUrl: 'screens/LeasingScreen/LeasingScreen.html', controller: 'LeasingScreenController'}).
when('/realtors', {templateUrl: 'screens/RealtorsScreen/RealtorsScreen.html', controller: 'RealtorsScreenController'}).
when('/realtor/:id', {templateUrl: 'screens/RealtorScreen/RealtorScreen.html', controller: 'RealtorScreenController'}).
otherwise({redirectTo: '/sellings'});
}]);
Unknown provider: SellingPropertySrvcProvider <- SellingPropertySrvc <- SellingsScreenController
'use strict';
servicesModule.factory(['SellingPropertySrvc', function(RESTSrvc) {
return {
getAll: function() {
return RESTSrvc.getPromise({
method: 'GET',
url: broker + 'selling-properties'
});
},
get: function(id) {
return RESTSrvc.getPromise({
method: 'GET',
url: broker + 'selling-property/' + id
});
}
};
}]);
'use strict';
appModule.controller('SellingsScreenController', ['SellingPropertySrvc', function($scope, SellingPropertySrvc) {
$scope.columns = [
{name: 'Район', property: 'region'},
{name: 'Улица', property: 'street'},
{name: 'Дом', property: 'house'},
{name: 'Количество комнат', property: 'rooms'},
{name: 'Размер квартиры', property: 'size'},
{name: 'Размер кухни', property: 'kitchen'},
{name: 'Размер ванной', property: 'bathroom'},
{name: 'Стоимость квартиры', property: 'cost'}
];
SellingPropertySrvc.getAll().then(
function(data) {
$scope.data = data;
}
);
}]);
Answer the question
In order to leave comments, you need to log in
And I forgot my brain, apparently. The service should have been described as
servicesModule.factory('name', function(RESTSrvc) {
return ....;
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question