Я новичок в Angular.js и застреваю при определении настраиваемой службы. Я следил за учебником по адресу https://docs.angularjs.org/tutorial.Пользовательское обслуживание не определено должным образом
Моего app.js:
var myApp = angular.module('myApp', [
'ngRoute',
'myControllers',
'myFilters',
]);
Моего services.js:
myApp.service('MathService', function() {
this.add = function(a, b) { return a + b };
this.subtract = function(a, b) { return a - b };
this.multiply = function(a, b) { return a * b };
this.divide = function(a, b) { return a/b };
});
Моего controllers.js:
var myControllers = angular.module('myControllers', []);
myControllers.controller('catalogCtrl', ['$scope', '$routeParams', MathService, '$http',
function($scope, $routeParams, $http) {
console.log(MathService.add(4,5));
}
]);
Все отлично работает до MathService.add (4, 5).
Ошибка:
Uncaught ReferenceError: MathService is not defined controllers.js:8(anonymous function)
я что-то отсутствует и не может найти что. Любая помощь приветствуется! Спасибо :-)
действительно, спасибо! – Jem
@Jem Отлично, я рад, что помог, вы должны, вероятно, отметить ответ, как принято. – developer10