I'm trying to create a service in ionic 1 but I'm getting the following error
Error: [$ injector: unpr] Unknown provider: heartTeamSrvcProvider
I'm trying to create a service in ionic 1 but I'm getting the following error
Error: [$ injector: unpr] Unknown provider: heartTeamSrvcProvider
Check the import of .js
in your index.html
.
He is saying that he does not recognize the provider for the reason that you did not inject the provider (heartTeamSrvc) into the controller, possibly your factory will also break for the reason that you did not inject $ http nor the $ scope in them Follow this good practice tutorial to set up your Controllers, Factorys, Services and ETC
adjust your factory:
(function () {
'use strict';
angular.module('firstApp')
.factory('heartTeamSrvc', heartTeamSrvc)
heartTeamSrvc.$inject = ['$http', '$scope'];
function heartTeamSrvc($http, $scope) {
var heartTeam = [];
return {
getHeartTeam: function() {
return $http.get('json/heartTeams.json').then(function(response){
heartTeam = response;
return heartTeam;
});
}
}
}
})
Do not forget that your controller will need adjustment as well, try to do anything yourself if you can not, add the Controller to your question that I will help you with.