在角度应用中加载织物js [英] load fabric js in angular application

查看:183
本文介绍了在角度应用中加载织物js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在我的角应用程序中使用bower下载并安装了fabricjs,但我无法加载它。

So i downloaded and installed fabricjs using bower inside of my angular application and i am having trouble loading it up.

我在我的应用程序之上有以下内容。 js文件。除了面料外其他所有东西都装好了

I have the following on top of my app.js file. Everything else loads fine except fabric

angular
 .module('myApp', [
   'flow',
   'fabric',
   'ngAnimate',
   'ngCookies',
   'ngResource',
   'ngRoute',
   'ngSanitize',
   'ngTouch',
   'ui.bootstrap',
   'ui.router',
   'controllers.main',
])
 .config( function ($stateProvider, $httpProvider, flowFactoryProvider ) {

当我加载页面时,我收到以下错误。

When i load the page i get the following error.

[$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

I am loading it up in my index.html

<script src="bower_components/fabric/dist/fabric.min.js"></script>

任何人都有任何成功在角度应用中加载结构?

Anyone have any success with loading fabric inside of their angular application?

推荐答案

即使这已经过时了,我也会尝试为未来的搜索者回答这个问题。

Even though this is old, I'll try to answer it for future searchers.

我一直在Angular中使用Fabric取得了巨大成功。

I've been using Fabric inside Angular with great success.

从我在代码中看到的内容例如,您正在尝试将标准fabic.min.js文件用作Angular模块。 Angular只将它视为纯JS,这就是为什么它会产生一个错误,说它无法找到它 - 因为没有任何名为fabric的Angular模块被声明为:

From what I can see in your code example, you are attempting to use the standard fabic.min.js file as a Angular Module. Angular only sees it as pure JS, that is why it generates an error saying it couldn't find it - because no Angular module called "fabric" was ever declared like:

angular.module('fabric', []);

如果你比较你列出的其他模块之一,比如ngCookies,你可以看到一个是怎样的设置。

If you compare one of the other modules you had listed, say ngCookies, you can see how one is setup.

这里发布的代码太多了,所以最简单的解决方案是利用或研究Michael Calkins的一些优秀作品:

It would be too much code to post here, so the easiest solution is to utilize or study some of the excellent work by Michael Calkins here:

https://github.com/michaeljcalkins/angular-fabric

他将所有内容都包含在指令中,这使得它易于实现。

He has everything wrapped up in directives and such which makes it easy to implement.

你也可以在这里玩它: http://codepen.io/michaeljcalkins/pen/Imupw

You can also play around with it live here: http://codepen.io/michaeljcalkins/pen/Imupw

希望能帮到某人。

这篇关于在角度应用中加载织物js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆