I'm encountering an issue with AngularJS 1.6, and the error message is stating:
Error: [ng:areq] Argument 'fn' is not a function, got undefined
I suspect the problem lies within my testService, and I'm seeking assistance in identifying the issue.
./app.js
import angular from 'angular';
import uiRouter from 'angular-ui-router';
import Components from './components/components';
import { TestComponent } from './test/test.component';
import { ApiConstant } from './constants';
import { TestService } from './services';
angular.module('myApp', [
uiRouter,
Components
])
.component('testPage', TestComponent)
.service('TestService', TestService)
.constant('ApiConstant', ApiConstant)
.config(($stateProvider) => {
'ngInject';
$stateProvider
.state('home', {
url: '',
template: '<test-page></test-page>'
});
});
./services/test.service.js
export const TestService = (ApiConstant) => {
'ngInject';
this.test = function() {
console.log(ApiConstant);
return ApiConstant;
};
};
./services/index.js
export * from './test.service';
./constants/api.js
export const ApiConstant = {
url: 'test'
};
./constants/index.js
export * from './api.constant';
./components/test.component.js
import template from './test.component.html';
import controller from './test.controller';
export const TestComponent = {
template,
controller
};
./components/test.controller.js
export default function TestController($scope, ApiConstant, TestService) {
'ngInject';
console.log(ApiConstant.url);
console.log(TestService.test());
}
While ApiConstant is functioning properly, TestService is causing an error. When I remove TestService from the controller, everything works fine. Any insights on what might be causing this?