所以我对 AngularJS
还很陌生,我似乎无法添加额外的模块,例如用于图形的 d3
。
所以我添加新模块的代码是
(function() {
'use strict';
angular
.module('infographicsModule', ['ngAnimate', 'ngCookies', 'ngTouch', 'ngSanitize', 'ngMessages', 'ngAria', 'ngResource', 'ui.router', 'ui.bootstrap', 'toastr']);
})();
但是如果我尝试添加 d3
作为附加模块,则会抛出错误
Uncaught Error: [$injector:modulerr] Failed to instantiate module infographicsModule due to:
Error: [$injector:modulerr] Failed to instantiate module d3 due to:
Error: [$injector:nomod] Module 'd3' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
有什么建议吗?如果您需要更多代码,我可以发布它。
最佳答案
也许发生这种情况是因为 D3 不是 Angular 模块。
您可以尝试通过以下链接执行此操作:https://github.com/WealthBar/angular-d3
或者您可以封装在服务或工厂中并从中调用。
关于javascript - AngularJS,无法添加模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35557165/