模块'mdPickers'不可用

时间:2017-06-14 03:16:04

标签: javascript angularjs

我正在构建一个Angular App,使用这个Angular Seed作为我的基础:https://github.com/angular/angular-seed

在我尝试使用these instructions添加模块mdPickers之前,一切运行良好,现在我收到以下错误。当我对moment.js或Angular Material没有任何问题时,我不明白是什么让mdPickers出错。

起初我以为我的依赖关系已经过时了,但我已经更新了它们并且错误没有改变。我知道我拼写了正确的模块,我知道我已经安装了它。我错过了什么?

在任何人问之前编辑:我确实检查了mdPicker所需的所有依赖项是否已安装,并且至少是所需的最低版本。他们是。

Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:modulerr] Failed to instantiate module myApp.view2 due to:
Error: [$injector:modulerr] Failed to instantiate module mdPickers due to:
Error: [$injector:nomod] Module 'mdPickers' 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.
http://errors.angularjs.org/1.6.4/$injector/nomod?p0=mdPickers

以下是我package.json的依赖关系部分:

"dependencies": {
  "angular-material": "^1.1.4",
  "moment": "^2.18.1",
  "moment-timezone": "^0.5.13",
  "mdPickers": "^0.7.5"
}

我的模块(如果更多的JS会有所帮助,请告诉我。但是还没有其他的东西):

angular.module("myApp.view2", [
  "ngRoute",
  "ngMaterial",
  "ngAnimate",
  "ngAria",
  "ngMessages",
  "mdPickers"
]); 

<body>底部的HTML脚本代码:

  <script src="bower_components/angular/angular.js"></script>
  <script src="bower_components/angular-route/angular-route.js"></script>
  <!-- Angular Material requires Angular.js Libraries -->
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script>
  <!-- Angular Material Library -->
  <script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js"></script><script src="app.js"></script>
  <script src="view1/view1.js"></script>
  <script src="view2/view2.js"></script>
  <script src="components/version/version.js"></script>
  <script src="components/version/version-directive.js"></script>
  <script src="components/version/interpolate-filter.js"></script>

2 个答案:

答案 0 :(得分:0)

检查此代码:https://codepen.io/alenaksu/pen/eNzbrZ

你需要Angular,Moment&amp; Angular Material作为脚本。

https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js

https://cdn.rawgit.com/alenaksu/mdPickers/0.7.4/dist/mdPickers.min.js

答案 1 :(得分:0)

使用。

安装mdPicker
 npm install mdPickers --save-dev
 bower install mdPickers --save

你的index.html

中给出了mdPicker的确切路径
 <script src="bower_components/mdPickers/mdPickers.js"></script>