Last active
August 30, 2017 20:27
-
-
Save paulosergioduff/fadd207b1c276f2673076860f5de3c9e to your computer and use it in GitHub Desktop.
Erro injetando dependência de service em angularJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> | |
<title></title> | |
<link rel="manifest" href="manifest.json"> | |
<!-- un-comment this code to enable service worker | |
<script> | |
if ('serviceWorker' in navigator) { | |
navigator.serviceWorker.register('service-worker.js') | |
.then(() => console.log('service worker installed')) | |
.catch(err => console.log('Error', err)); | |
} | |
</script>--> | |
<link href="lib/ionic/css/ionic.css" rel="stylesheet"> | |
<link href="css/style.css" rel="stylesheet"> | |
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above | |
<link href="css/ionic.app.css" rel="stylesheet"> | |
--> | |
<!-- ionic/angularjs js --> | |
<script src="lib/ionic/js/ionic.bundle.js"></script> | |
<!-- cordova script (this will be a 404 during development) update--> | |
<script src="cordova.js"></script> | |
<!-- your app's js --> | |
<script src="js/app.js"></script> | |
<script src="js/route.js"></script> | |
<script src="lib/service1.js"></script> | |
<script src="js/modules/projeto.js"></script> | |
<script src="js/controller/Template1Ctrl.js"></script> | |
</head> | |
<body ng-app="projeto"> | |
<ion-nav-view></ion-nav-view> | |
</body> | |
</html> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ionic.bundle.js:26799 Error: [$injector:unpr] Unknown provider: $Template1ServiceProvider <- $Template1Service <- Template1Ctrl | |
http://errors.angularjs.org/1.5.3/$injector/unpr?p0=%24Template1ServiceProvider%20%3C-%20%24Template1Service%20%3C-%20Template1Ctrl | |
at ionic.bundle.js:13443 | |
at ionic.bundle.js:17793 | |
at Object.getService [as get] (ionic.bundle.js:17946) | |
at ionic.bundle.js:17798 | |
at getService (ionic.bundle.js:17946) | |
at injectionArgs (ionic.bundle.js:17970) | |
at Object.instantiate (ionic.bundle.js:18012) | |
at $controller (ionic.bundle.js:23417) | |
at Object.self.appendViewElement (ionic.bundle.js:59908) | |
at Object.render (ionic.bundle.js:57901) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
angular.module('projeto.projeto') | |
.service('Template1Service', function ($scope) { | |
//conteudo | |
} | |
}); | |
})(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
angular.module('projeto.projeto') | |
.controller('Template1Ctrl', function ($scope, $Template1Service, $state, $ionicPopup, $http) { | |
$scope.choice = {}; | |
$scope.data = {}; | |
$scope.data.address = ""; | |
$scope.selecao = []; | |
// Configura os servidores do service $http | |
$scope.APIfavConfig = "lib/APIfav.json"; // Arquivo JSON para ambiente de testes | |
$scope.APIhistConfig = "lib/APIhist.json"; | |
// função init que aplica entrega de dados da API | |
var init = function () { | |
var favResult = $http.get($scope.APIfavConfig) | |
.then(function(res){ | |
$scope.favoritos = res.data; | |
// adciona opções oriunda do JSON a $scope.selecao | |
for (var i = 0; i < 3; i++) { | |
$string = 'escolha:'+$scope.favorito; | |
$scope.selecao.push($string); | |
} | |
// adciona opções oriunda do JSON a $scope.choice | |
}); | |
var histResult = $http.get($scope.APIhistConfig) | |
.then(function(res){ | |
$scope.historico = res.data; | |
}); | |
} | |
init(); | |
loadSavedAddress(); | |
function loadSavedAddress() { //Chama API que carrega favoritos e historico nas abas correspondentes | |
} | |
$scope.saveFavouriteIfCheckboxMarked = function() { //Chama API que salva endereço que está no campo address do template | |
var resultado = window.document.getElementById('resultado').value; // Pega resultado do campo de endereço | |
console.log('Endereço capturado: '+resultado+$scope.choice.choice); | |
} | |
$scope.loadAddressIntoField = function($escolha, $origem) { //Carrega o favorito ou endereço do histórico selecionado no campo do address do template e vai para aba Meus Endereços | |
console.log('funcao loadSavedAddress acionada. Usuário escolheu opção: '+$escolha+' de(o) '+$origem); | |
} | |
$scope.pegaResultado = function() { //Carrega o favorito ou endereço do histórico selecionado no campo do address do template e vai para aba Meus Endereços | |
var resultado = window.document.getElementById('resultado').value; | |
console.log(resultado); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment