0
I am trying to create a service on Ionic 1 but am getting the following error
Error: [$injector:unpr] Unknown Provider: heartTeamSrvcProvider <- heartTeamSrvc <- teamCtrl
heartTEamSrvc code
(function) {
'use strict';
var app = angular.module('firstApp');
app.factory('heartTeamSrvc', function($http, $scope) {
var heartTeam = [];
return {
getHeartTeam: function() {
return $http.get('json/heartTeams.json').then(function(response){
heartTeam = response;
return heartTeam;
});
}
}
})
})
Controller
$scope.listHeart = function(heartTeamSrvc) {
$scope.heartTeam = getHeartTeam();
}
What am I doing wrong?
EDITED
NEW CTRL
function listHeartTeam(response) {
this.heartTeam = getHeartTeam();
}
You put the import on
script
offactory
?– Sorack
Dude, that’s right, I forgot to import it on the index. Thank you.
– Leonardo
@Leonardo pera ai I will help you, rs
– Diogo Henrique Fragoso de Oliv
Thank you @Diogohenriquefragosodeoliv looked at the tutorial you sent me and I noticed that a lot of code that was made is not recommended in the publication rsrs
– Leonardo
kkkk @Leonardo, Rlx that when I started in Angular was more lost than blind in shooting, kkkk
– Diogo Henrique Fragoso de Oliv
Has any response helped solve the problem and can address similar questions from other users? If so, make sure to mark the answer as accepted. To do this just click on the left side of it (below the indicator of up and down votes).
– Sorack