Я собираюсь создать контроллер/службу для состояния, которое через мой собственный метод запроса предоставляет список клиентов.
Это странно, потому что метод «GETALL» отлично работает, проблема запрос или какой-либо другой метод прибудет ... в любом случае, здесь есть служба:
(function() {
'use strict';
angular
.module('omi.services')
.factory('cliente', clienteFactory);
clienteFactory.$inject = ['$http'];
function clienteFactory ($http) {
var baseUrl = 'http://localhost:3000/omi/v1/clientes/';
var service = {
create : create,
getAll : getAll,
getOne : getOne,
query : query,
remove : remove,
update : update
};
return service
function create (clienteData) {
// body...
} // end create
function getAll() {
return $http.get(baseUrl)
.success(getAllComplete)
.error(getAllOnError);
function getAllComplete (data) {
return data;
}
function getAllOnError (data) {
return data;
}
}
} // end facturaFactory
function getOne (cliente) {
return $http.get(baseUrl + cliente)
.success(getOneComplete)
.error(getOneOnError);
function getOneComplete (data) {
return data;
}
function getOneOnError (data) {
return data;
}
} // end getOne
function query (query) {
return $http.get(baseUrl + 'buscar' + query)
.success(queryComplete)
.error(queryOnError);
function queryComplete (data) {
return data;
}
function queryOnError (error) {
return data;
}
} // end query
function remove (factura) {
// body
} // end remove
function update (clienteData) {
// body...
} // end update
})();
это еще не завершено, но все состав. Таким образом, проблема обжигают в контроллере:
(function(){
'use strict';
angular
.module('omi.controllers')
.controller('clientReportsResult', clientReports);
clientReports.$inject = ['$stateParams', 'cliente'];
function clientReports ($stateParams, cliente) {
/* jshint validthis: true */
var vm = this;
vm.clientes = [];
var id = $stateParams.data;
var query = "?id=" + id;
fire();
function fire() {
cliente.query(query).then(function(data) {
vm.clientes = data.data.clientes;
});
}
}
})();
Это огонь мне это отслеживающий:
"Error: $http is not defined
[email protected]://localhost:8080/js/services/clientes.service.js:55:7
[email protected]://localhost:8080/js/controllers/clientes.reports.results.js:21:9
[email protected]://localhost:8080/js/controllers/clientes.reports.results.js:18:7
[email protected]://localhost:8080/js/libs/angular/angular.js:4182:14
[email protected]://localhost:8080/js/libs/angular/angular.js:4190:27
$ControllerProvider/this.$get</<@http://localhost:8080/js/libs/angular/angular.js:8449:18
$ViewDirectiveFill/<.compile/<@http://localhost:8080/js/libs/angular-ui-router/release/angular-ui-router.js:3897:28
[email protected]://localhost:8080/js/libs/angular/angular.js:8213:9
[email protected]://localhost:8080/js/libs/angular/angular.js:7722:1
[email protected]://localhost:8080/js/libs/angular/angular.js:7075:13
[email protected]://localhost:8080/js/libs/angular/angular.js:6954:30
[email protected]://localhost:8080/js/libs/angular-ui-router/release/angular-ui-router.js:3839:23
$ViewDirective/directive.compile/<@http://localhost:8080/js/libs/angular-ui-router/release/angular-ui-router.js:3807:9
[email protected]://localhost:8080/js/libs/angular/angular.js:8213:9
[email protected]://localhost:8080/js/libs/angular/angular.js:7722:1
[email protected]://localhost:8080/js/libs/angular/angular.js:7075:13
[email protected]://localhost:8080/js/libs/angular/angular.js:7078:13
[email protected]://localhost:8080/js/libs/angular/angular.js:6954:30
$ViewDirectiveFill/<.compile/<@http://localhost:8080/js/libs/angular-ui-router/release/angular-ui-router.js:3905:9
[email protected]://localhost:8080/js/libs/angular/angular.js:8213:9
[email protected]://localhost:8080/js/libs/angular/angular.js:7722:1
[email protected]://localhost:8080/js/libs/angular/angular.js:7075:13
[email protected]://localhost:8080/js/libs/angular/angular.js:6954:30
[email protected]://localhost:8080/js/libs/angular-ui-router/release/angular-ui-router.js:3839:23
$ViewDirective/directive.compile/</<@http://localhost:8080/js/libs/angular-ui-router/release/angular-ui-router.js:3801:11
$RootScopeProvider/this.$get</[email protected]://localhost:8080/js/libs/angular/angular.js:14702:15
transitionTo/$state.transition<@http://localhost:8080/js/libs/angular-ui-router/release/angular-ui-router.js:3218:11
[email protected]://localhost:8080/js/libs/angular/angular.js:13170:27
scheduleProcessQueue/<@http://localhost:8080/js/libs/angular/angular.js:13186:27
$RootScopeProvider/this.$get</[email protected]://localhost:8080/js/libs/angular/angular.js:14383:16
$RootScopeProvider/this.$get</[email protected]://localhost:8080/js/libs/angular/angular.js:14199:15
$RootScopeProvider/this.$get</[email protected]://localhost:8080/js/libs/angular/angular.js:14488:13
[email protected]://localhost:8080/js/libs/angular/angular.js:9646:36
[email protected]://localhost:8080/js/libs/angular/angular.js:9836:7
[email protected]://localhost:8080/js/libs/angular/angular.js:9777:1
" "<div ui-view="" class="details ng-scope">"
Я triying, чтобы решить эту проблему, но я не могу понять эту проблему, почему это Ошибка появляется здесь? В других контроллерах, где я использую метод getAll, все работает нормально!
Я не заметил, спасибо! – Nano