2

I am using ngDocs to document directives in angular. The documentation and the example is working well but the Demo is not generated because the main module which the directives are based on is declared after the page is generated. so i get the error: "Module 'main-module' is not available!"

Here is my main module:

define(['angular'], function(angular){
    var module = angular.module('app.directivesModule', []);
    return module;
});

here is my directive:

/**
 * @ngdoc directive
 * @name app.directivesModule:hello
 *
 *@example
 <example module="app.directive">
 <file name="index.html">
 <hello></hello>
 </file>
 </example>
**/

define('hello', ['directivesModule'], function(directivesModule){
    directivesModule.directive('hello', function(){
        restrict: 'E',
        scope: {},
        templateUrl: hello.html
        link: function(scope){
        }
     });
});

What do i have to add in order to make angular run the main module before generating the example demo?

i tried to export the main module for use in the directive by using the @exports tag but it doesn't seems to work, and i get the same error.

user2436448
  • 445
  • 4
  • 7
  • 18
  • You can define path to your module in Gruntfile in scripts section of ngdocs options. But it will add this script to all of your documentation pages. The same thing with directives. You have to add path to them in your Gruntfile to get your example work. If you find out how to do this for separate pages, please, let me know. – Anton Feb 29 '16 at 09:56

0 Answers0