【问题标题】:Angular JS Module Injecting ErrorAngular JS 模块注入错误
【发布时间】:2016-05-30 01:33:05
【问题描述】:

最近我一直在使用 Angular JS,它很棒。但是,我不是很了解里面的注入。我几乎在每个页面上都使用了这种模式,而且效果很好。

var workoutApp = angular.module('workoutApp', []);
workoutApp.controller('workoutControllers', ['$scope', '$http', '$window', function ($scope, $http, $window) {
        //do something with $scope.

现在我想使用 ngMaterial http://codepen.io/anon/pen/VeNqYB 实现自动完成

语法与我一直在做的完全不同,所以我真的很困惑。我试着用这种方式注入模块,

var workoutApp = angular.module('workoutApp', ['ngMaterial', 'ngMessages', 'material.svgAssetsCache']);

但不断出错。任何人都可以分享一些想法吗?

【问题讨论】:

    标签: javascript angularjs


    【解决方案1】:

    根据文档,ngMaterial 不仅仅依赖于角度。

    在 CDN 示例 (https://github.com/angular/material#cdn) 中,您可以看到依赖关系。

    <!-- Angular Material Dependencies -->
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-aria.js"></script>
    

    听起来修复就像添加这些依赖项一样简单。

    相关问题

    Installing Angular Material, "Failed to instantiate module ngMaterial" even though I'm using angular version 1.3.0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-11
      • 1970-01-01
      • 2016-07-14
      • 2017-01-14
      • 2017-08-12
      • 1970-01-01
      • 2016-02-12
      • 1970-01-01
      相关资源
      最近更新 更多