在AnguarJS中包含include ng-material之后,由于“无法实例化模块gupaApp而导致错误?

时间:2018-12-08 12:49:43

标签: angularjs angularjs-material

我已经使用angularjs创建了网站,并且在我们的网站中使用了angular-material,但是我正确地正确包含了脚本文件,但是在将['ngMaterial']作为模块中的依赖项后出现了错误,我的代码有什么问题。

var app = angular.module("gupaApp", ['ngMaterial']);
app.controller("gupaContr", function($scope) {
  console.log('hii');
})
<html ng-app="gupaApp">
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
  <link rel="stylesheet" href="https://gitcdn.xyz/repo/angular/bower-material/master/angular-material.css">
  <script src="https://gitcdn.xyz/repo/angular/bower-material/master/angular-material.js"></script>
  <script type="text/javascript" src="app/controller/gupaController.js"></script>

  <body ng-controller="gupaContr">
    <md-toolbar md-scroll-shrink>
      <div class="md-toolbar-tools">
        <div flex="50">
          <h3 class="title"><span>My Title</span></h3>
        </div>
        <div flex="50" layout layout-align="end center">

          <md-button class="md-fab" aria-label="Time">
            <md-icon icon="/img/icons/ic_access_time_24px.svg" style="width: 24px; height: 24px;"></md-icon>
          </md-button>
        </div>
      </div>
    </md-toolbar>
  </body>
</html>

1 个答案:

答案 0 :(得分:1)

您还需要添加对 angular-animate.js angular-aria.js 的引用

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-animate.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-aria.js"></script>

确保匹配您使用的版本

PLUNKER DEMO