模块' ngMaterial'不可用!您要么错误拼写了模块名称,要么忘记加载它

时间:2017-04-28 18:34:43

标签: angularjs

我正在使用AngularJS v1.6.0。

我的代码:

var app= angular.module("appp",["ngMaterial"]);

错误:Module 'ngMaterial' is not available! You either misspelled the module name or forgot to load it.

此SO solution表示包括ngAriangAnimate,我这样做了:

var app= angular.module("charter",["ng","ngAnimate","ngAria","ngMaterial"]);

现在我收到了这个错误:

Module 'ngAnimate' is not available! You either misspelled the module name or forgot to load it.

在我的HTML <head><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.0/angular.js"></script>

我是否需要更多依赖项?

1 个答案:

答案 0 :(得分:2)

您错过了将角色包含在角材料中。 来自官方Angular Material Codepen

<html lang="en" >
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Angular Material style sheet -->
  <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css">
</head>
<body ng-app="BlankApp" ng-cloak>
  <!--
    Your HTML content here
  -->  

  <!-- Angular Material requires Angular.js Libraries -->
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script>

  <!-- Angular Material Library -->
  <script src="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js"></script>

  <!-- Your application bootstrap  -->
  <script type="text/javascript">    
    /**
     * You must include the dependency on 'ngMaterial' 
     */
    angular.module('BlankApp', ['ngMaterial']);
  </script>

</body>
</html>

<!--
Copyright 2016 Google Inc. All Rights Reserved. 
Use of this source code is governed by an MIT-style license that can be in foundin the LICENSE file at http://material.angularjs.org/license.
-->