Question

I have defined a directive save-item and defined that in a .js file as below

main.js

define([
  './controllers', './states','./directives']
 , function(controllers) {
  var mod = angular.module("user.settings", ['ui.router', 'user.settings.states']);

  // Page Controller 
  mod.controller('SalesController', controllers.sales);
  mod.controller('ItemEntryController', controllers.items);

  // Directives
  mod.directive("saveItem", directives.saveItem);
  return mod;
});

directives.js

define(['../../common/directives/save-item'], function( 
  saveItem) {
  "use strict";

  return {
    saveItem: saveItem    
  };

});

save-item.html

Save Item

When I run, I get the below error

Uncaught ReferenceError: directives is not defined at main.js

in the line below mod.directive("saveItem", directives.saveItem);

Please let me know where I went wrong

Was it helpful?

Solution

You need to pass in directives:

define(['./controllers', './states','./directives'],
    function(controllers, states, directives) {
        ....
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top