包括特定的Angular模块

时间:2015-12-08 17:43:53

标签: angularjs module

我正在尝试包含一个github模块angular-drag-drop。我是棱角分明的新手而且我失败了。自述文件显示了使用webpack或browserify的示例,但我没有使用它们。我也提出了一个问题,但我也想在这里问一下。

odds.js:

(function(){
    var app = angular.module('pokerApp', ['angular-drag-drop']);
})(); 

的index.html:

<!DOCTYPE html>
<html lang="en">

<head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.js"></script>
    <script src="lib/angular-drag-drop.min.js"></script>
    <script src="odds.js"></script>
</head>
<body>
    <div ng-app = "pokerApp" ng-init = "cards = ['As','Ks','Qs','Js','Ts','9s','8s','7s','6s','5s','4s','3s','2s',
                                 'Ah','Kh','Qh','Jh','Th','9h','8h','7h','6h','5h','4h','3h','2h',
                                 'Ad','Kd','Qd','Jd','Td','9d','8d','7d','6d','5d','4d','3d','2d',
                                 'Ac','Kc','Qc','Jc','Tc','9c','8c','7c','6c','5c','4c','3c','2c']"> 

        <!--<div drag-container>KKKKKKKKKKKK</div>-->

        <!--
        <div drag-container="model"
            on-drag-start="ctl.handleDragStart($event, data)"
            on-drag-end="ctl.handleDragEnd($event, data)"
        ></div>-->
    </div>

</body>
</html>

文件angular-drag-drop.min.js是从the github repo复制的。我得到的错误是:

Uncaught Error: [$injector:modulerr] Failed to instantiate module pokerApp due to:
Error: [$injector:modulerr] Failed to instantiate module angular-drag-drop due to:
Error: [$injector:nomod] Module 'angular-drag-drop' 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.

我也试过'AngularDragDrop'而不是'angular-drag-drop',但我得到了同样的错误。

2 个答案:

答案 0 :(得分:0)

需要learts.dragDrop 加载模块,我也看了API,我认为模块名称应该是

angular-drag-drop

而不是

(function(){
    var app = angular.module('pokerApp', ['learts.dragDrop']);
})(); 

<强> odds.js:

(DTE2)GetService(typeof(SDTE))

答案 1 :(得分:0)

开发者已在问题中发布了答案。我需要导入&#34; filearts.dragDrop&#34;而不是导入require.js。它现在有效。