У меня есть модуль, называемый таймером, в который я включил свой контроллер и службы. Это мой файл module.js.AngularJS не может загрузить завод в контроллер
(function() {
'use strict';
angular.module('timesheet.timer',[
'timesheet.timer.controllers',
'timesheet.timer.services'
]).filter('digits', function() {
return function(input) {
if (input < 10) input = '0' + input;
return input;
}
});
angular.module('timesheet.timer.controllers',[]);
angular.module('timesheet.timer.services',[]);
})();
Фильтр - это настраиваемый фильтр, который мне нужен, игнорируйте его.
В моих услугах я имею
(function() {
'use strict';
angular
.module('timesheet.timer.services')
.factory('Timer', Timer);
Timer.$inject = ['$http'];
function Timer($http){
var timer = {
get: get
};
return timer;
function get(dateString,emp_id){
return $http.get("/timesheet/employee/"+emp_id+"/tasks/?date=" + dateString);
}
}
});
Мой главный app.js выглядит следующим образом.
(function() {
'use strict';
angular
.module('timesheet', [
'angular.filter',
'chart.js',
'ngCookies',
'ngStorage',
'ui.bootstrap',
'daterangepicker',
'xeditable',
'timesheet.routes',
'timesheet.timer',
'timesheet.authentication'
]).factory('httpRequestInterceptor',['$cookies', function ($cookies) {
return {
request: function (config) {
var token = $cookies.get('Token');
if(token) {
config.headers['token'] = token;
}
return config;
}
};
}]).config(['$httpProvider',function($httpProvider) {
$httpProvider.interceptors.push('httpRequestInterceptor');
}])
.run(function(editableOptions) {
editableOptions.theme = 'bs3'; // bootstrap3 theme. Can be also 'bs2', 'default'
});
angular
.module('timesheet.routes', ['ngRoute']);
})();
Как только я добавить таймер в зависимости в моем контроллере я получаю сообщение об ошибке ошибки: $ форсунки: unpr Неизвестного Provider
Моего контроллера как этого
(function() {
angular.module('timesheet.timer.controllers')
.controller('ManualTableController',ManualTableController);
ManualTableController.$inject=['$scope','$filter','$http','$uibModal','$rootScope','$filter','Timer'];
function ManualTableController($scope, $filter, $http, $uibModal, $rootScope){
$rootScope.totalDuration = "";
$scope.noTask = false;
$scope.error = false;
$rootScope.tasks = "";
var emp_id = $rootScope.emp_id;
$scope.dateString = getDateString($scope.dt);
$scope.date = angular.copy($scope.dt);
Timer.get($scope.dateString,emp_id).then(timerSuccessFn, timerErrorFn);
function timerSuccessFn(data, status, headers, config) {
console.log(data);
}
}
});
Что же я делать не так? почему завод не вводится в мой контроллер. Кроме того, я включил все файлы JS в моем base.html
вам необходимо ввести timesheet.timer.services на ваш app.js – M14