Javascript 在角度应用程序中加载fabric js
因此,我在angular应用程序中使用bower下载并安装了fabricjs,但在加载时遇到了问题 我的app.js文件上面有以下内容。除了织物外,其他东西都很好Javascript 在角度应用程序中加载fabric js,javascript,angularjs,html5-canvas,fabricjs,Javascript,Angularjs,Html5 Canvas,Fabricjs,因此,我在angular应用程序中使用bower下载并安装了fabricjs,但在加载时遇到了问题 我的app.js文件上面有以下内容。除了织物外,其他东西都很好 angular .module('myApp', [ 'flow', 'fabric', 'ngAnimate', 'ngCookies', 'ngResource', 'ngRoute', 'ngSanitize', 'ngTouch', 'ui.bootstrap',
angular
.module('myApp', [
'flow',
'fabric',
'ngAnimate',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch',
'ui.bootstrap',
'ui.router',
'controllers.main',
])
.config( function ($stateProvider, $httpProvider, flowFactoryProvider ) {
当我加载页面时,我得到以下错误
[$injector:modulerr] Failed to instantiate module fabric due to: [$injector:nomod] Module 'fabric' is not available! You either misspelled the module name or forgot to load it.
我正在把它加载到index.html中
<script src="bower_components/fabric/dist/fabric.min.js"></script>
任何人在angular应用程序中加载fabric是否成功?即使这已经很旧了,我还是会尝试为未来的搜索者解答这个问题 我一直在使用织物内角与巨大的成功 从我在代码示例中看到的情况来看,您正在尝试将标准fabic.min.js文件用作角度模块。Angular只将其视为纯JS,这就是为什么它会生成一个错误,说它找不到它-因为没有任何称为fabric的Angular模块被声明为:
angular.module('fabric', []);
如果您比较列出的其他模块中的一个,比如ngCookies,您可以看到一个模块是如何设置的
在这里发布的代码太多了,因此最简单的解决方案是利用或研究Michael Calkins的一些优秀作品:
他把一切都写进了指令中,这样就很容易实施了
您也可以在这里现场玩:
希望这能帮助别人