ngdoc example block not working if i add angular material as dependency

199 views Asked by At

My grunt ngdocs task below.

`
    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'
            }
        }
`

My ngdoc example block copied from angular documentation. I just added 'ngMaterial' as a dependency.

`
 <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>

`

Below is the error that I get.

`
    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
`

If i remove 'ngMaterial' as depenedency, this example block works absolutely fine. I am using Angular 1.4.3 and Angular-material 1.0.5. Please help.

0

There are 0 answers