如何在不收到错误的情况下正确实例化angular-aria和ngmaterial模块?

时间:2017-01-01 20:46:36

标签: angularjs npm dependency-injection angularjs-material

我试图包含ng-material,起初我得到了'Failed to instantiate module'错误,然后我也npm安装了angular-aria,因为它显然是ngmaterial的依赖,并在加载ngmaterial之前加载它。现在我没有得到同样的错误,不再是针对ngmaterial,而是针对angular-aria:

ailed to instantiate module angular-aria due to:
Error: [$injector:nomod] Module 'angular-aria' 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.

我觉得我已经阅读过每一篇类似的帖子,但没有什么真的有用。任何想法都会非常感激! PS。如果它对任何事情都很重要,我会使用gulp。如果npm安装和bower安装之间有区别,也有人可以向我解释一下吗? 谢谢!

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

<head>
    <base href="/" />
    <title>Candles Shop</title>
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Josefin+Slab:700" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Pacifico" />
    <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Rammetto+One" />
    <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Gloria+Hallelujah" />
    <link rel="stylesheet" type="text/css" href="/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/materialize-css/bin/materialize.css">
   <link rel="stylesheet" type="text/css" href="/angular-input-stars-directive/angular-input-stars.css">
    <link rel="stylesheet" type="text/css" href="/style.css" />
    <script type="text/javascript" src="/jquery/dist/jquery.min.js"></script>
    <script src="/lodash/index.js"></script>
    <script src="/angular/angular.js"></script>
    <script src="/angular-animate/angular-animate.js"></script>
    <script src="/angular-ui-router/release/angular-ui-router.js"></script>
    <script src="/angular-ui-router-styles/ui-router-styles.js"></script>
    <script src="/angular-ui-bootstrap/ui-bootstrap.js"></script>
    <script src="/angular-ui-bootstrap/ui-bootstrap-tpls.js"></script>
    <script src="/angulike/angulike.js"></script>
    <script src="/angular-password/angular-password.js"></script>
    <script type="text/javascript" src="/materialize-css/bin/materialize.js"></script>
    <script type="text/javascript" src="/angular-materialize/src/angular-materialize.min.js"></script>
    <script type="text/javascript" src="/angular-input-stars-directive/angular-input-stars.js"></script>
    <script src="https://js.stripe.com/v2/"></script>
    <script type="text/javascript" src="/angular-stripe/release/angular-stripe.js"></script>

    <script src="/angular-aria/angular-aria.js"></script> 
    <script src="/angular-material/angular-material.min.js"></script>
    <script type="text/javascript" src="/angular-sidebar/angular-sidebar.css"></script>

    <script src="/socket.io-client/socket.io.js"></script>
    <script src="/main.js"></script>
</head>

<body ng-app="candleShop" ng-class="{'home-page': $state.includes('home'), 'store-page' : $state.includes('store')}">
    <navbar></navbar>
    <div id="main" class="container" ui-view autoscroll='true'></div>
</body>

</html>

app.js:

'use strict';

window.app = angular.module('candlesApp', ['ng', 'angulike', 'fsaPreBuilt', 'ngPassword', 'ui.router', 'ui.bootstrap', 'ui.materialize', 'angular-input-stars','angular-stripe', 'ngAnimate', 'angular-aria', 'ngMaterial', 'angular-sidebar']);

1 个答案:

答案 0 :(得分:0)

如果你在这里查看angular-aria的文档:https://docs.angularjs.org/api/ngAria

你会看到:

  

最后,通过将模块添加为应用程序来加载应用程序中的模块   依赖模块:

     

angular.module('app',['ngAria']);

通常情况下,文件名和模块名称不一样。请务必查看文档