【问题标题】:How to setup Angular Material for AngularJS 1.3.0如何为 AngularJS 1.3.0 设置 Angular 材质
【发布时间】:2017-09-15 12:02:23
【问题描述】:

我正在尝试在使用 Angular 1.3.0(Angular Material 支持的最低版本)的应用中实现 Angular Material。

我有一个 index.php,其中包含以下内容:

<script src="bower_components/jquery/jquery.min.js"></script>
<!-- Angular Material style sheet -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.3/angular-material.min.css">
<script src="bower_components/angular/angular.min.js"></script>
<!-- Angular Material requires Angular.js Libraries -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular-animate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular-aria.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular-messages.min.js"></script>

在我的 app.js 中,我已将新的 ngMaterial 添加到下面的模块部分..

var myApp = angular.module('myApp', [ 'myControllers', 'myFilters', 'myServices', 'myDirectives',
    'ui.calendar', 'ngMaterial']);

当我在浏览器中运行应用程序时,我在控制台日志中收到以下错误,单击该错误是 Angular 网站上的以下错误 -

Module 'ngMaterial' 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.

谁能指出为什么它没有正确加载?

【问题讨论】:

  • 你怎么还在用 ng1.3 而不是 2.x 或 4.x?
  • @mast3rd3mon 它是一个旧项目,我们暂时无法升级到 2.x 或 4.x
  • 为什么不能升级?

标签: angularjs angularjs-module angularjs-material


【解决方案1】:

您只添加了angular-material.min.css 文件。还需要添加angular-material.min.js 文件。将此脚本添加到索引

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.3/angular-material.min.js"></script>

【讨论】:

  • 对不起,你是对的 - 我现在得到一个未知的提供者:$$jqLit​​eProvider 错误,我现在开始调试,谢谢你的建议有点帮助:)
  • @Zabs 当角度版本和角度动画版本不兼容时会导致异常。将角度版本更新为等于角度动画版本的版本
  • 嗯好吧,我不应该如何判断哪些版本与 Angular 1.3.0 不兼容?
  • 如果版本不相等则不兼容
  • sachila - 我将深入研究为什么这不适用于 Angular Material,即使依赖项都使用 1.3.0(与我当前使用的 AngularJS 版本相同的版本号)再次感谢
猜你喜欢
  • 2018-06-17
  • 2019-12-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-23
  • 1970-01-01
  • 2016-01-25
  • 2018-09-19
相关资源
最近更新 更多