1

下面是我的 grunt ngdocs 任务。

`
    ngdocs: {
            options: {
                dest: 'site/docs',
                html5Mode: false,
                startPage: '/api',
                scripts: [
                    'bower_components/angular/angular.js'
                    'bower_components/angular-animate/angular-animate.js',
                    'bower_components/angular-material/angular-material.js'
                ]
            },
            api: {
                src: ['app/**/*.js','!app/**/*-spec.js','app/index.ngdoc'],
                title: 'Docs'
            }
        }
`

我的 ngdoc 示例块是从 Angular 文档中复制的。我刚刚添加了“ngMaterial”作为依赖项。

`
 <example module="sample">
    <file name="index.html">
<div ng-controller="ExampleController">
  <form novalidate>
    <h3>User 1</h3>
    Name: <input type="text" ng-model="user1.name">
    Age: <input type="number" ng-model="user1.age">

    <h3>User 2</h3>
    Name: <input type="text" ng-model="user2.name">
    Age: <input type="number" ng-model="user2.age">

    <div>
      <br/>
      <input type="button" value="Compare" ng-click="compare()">
    </div>
    User 1: <pre>{{user1 | json}}</pre>
    User 2: <pre>{{user2 | json}}</pre>
    Equal: <pre>{{result}}</pre>
  </form>
</div>
</file>
<file name="script.js">
     angular.module('sample', ['ngMaterial']).controller('ExampleController', ['$scope', function($scope) {
         $scope.user1 = {};
         $scope.user2 = {};
         $scope.result;
         $scope.compare = function() {
          $scope.result = angular.equals($scope.user1, $scope.user2);
     };
}]);


</file>
</example>

`

以下是我得到的错误。

`
    angular.js:12330 Error: [$injector:modulerr] Failed to instantiate module sample due to:
    Error: [$injector:modulerr] Failed to instantiate module ngMaterial due to:
    Error: [$injector:modulerr] Failed to instantiate module material.components.fabSpeedDial due to:
    TypeError: Cannot read property 'apply' of undefined
`

如果我将 'ngMaterial' 作为依赖项删除,则此示例块绝对可以正常工作。我正在使用 Angular 1.4.3 和 Angular-material 1.0.5。请帮忙。

4

0 回答 0