![](/img/trans.png)
[英]Angular “angular.js:14110 Error: [ng:areq] Argument 'fn' is not a function, got undefined” exception on controller instantiation
[英]angular.js Uncaught Error: [ng:areq] Argument 'fn' is not a function, got Moment while working on angular-ui-calendar based calendar widget
我已经在angular angular.js中找到了该主题的早期es6 import moment.js错误:[ng:areq]参数'fn'不是函数,得到Moment ,不幸的是,它没有解决。 因此,我决定自己刷新这个问题,然后再问一次。
我正在从app.js文件中导入moment.js,这是我的应用程序主模块初始化的来源:
...
import 'jquery/dist/jquery.js';
import moment from 'moment/moment.js';
import 'fullcalendar/dist/fullcalendar.min.js';
import 'fullcalendar/dist/gcal.min.js';
import 'angular-ui-calendar/src/calendar.js';
const app = angular
.module('app', [
uiRouter,
uiBootstrap,
'ui.bootstrap.datetimepicker',
uiMask,
cookies,
ngTranslate,
'ng-currency',
moment,
'ui.calendar',
sanitize,
uiSelect,
uiNotification,
'mm.acl',
Common.name,
Components.name
])
上面显示的moment.js lib的导入和依赖项注入方式,导致这样的错误:
Uncaught Error: [ng:areq] Argument 'fn' is not a function, got Moment
http://errors.angularjs.org/1.5.8/ng/areq?p0=fn&p1=not%20a%20function%2C%20got%20Moment
真的不知道如何使其工作。 同样,使用webpack进行应用程序构建过程,但是所有新的库和指令都可以通过ES6 import
或require
语句直接导入到应用程序的代码中。 我没有使用webpack配置来构建和加载webpack的每个第三方模块。 没有任何线索如何导入moment.js并使之工作
您应该使用angular-moment
而不是原生的momentjs包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.