angularjs - Problems loading module when separating files into directories -
i'm working on angularjs 1 , rails 4.2 application. i'm using angularrailstemplates load angularjs templates.
i have of angularjs controllers, config, routing, , factories in one single file. i'm trying separate these entities designated directories (i.e. see below).
| application.js | controllers | guest.js | user.js | factories | lists.js | templates | home.html | dashboard.html
i have separated controller , factory files modules. example, in controller directory, have 2 controller files:
controllers/guest.js
angular.module('diction.controllers') /* guest controller * controller static clientside guest users * */ .controller('guestctrl', ['$scope', '$stateparams', 'auth', '$http', '$window', // logic }]);
controllers/user.js
angular.module('diction.controllers') /* user controller * controller users * */ .controller('userctrl', ['$scope', '$stateparams', 'auth', '$http', '$window', // logic }]);
i'm trying load these controller modules in application.js file, looks this.
//= require angular-rails-templates //= require_tree . angular.module('diction', [ 'ui.router', 'templates', 'diction.controllers' ]) /* routing configuration various 'states' * */ .config(['$stateprovider', '$urlrouterprovider', // set state providers function($stateprovider, $urlrouterprovider) {$stateprovider // home .state('home', { url: '/home', templateurl: 'home.html', controller: 'guestctrl', }) } ]);
when view page, i'm getting "module unavailable" error:
error: $injector:nomod module unavailable
module 'diction.controllers' not available! either misspelled module name or forgot load it. if registering module ensure specify dependencies second argument.
any helpful tips appreciated.
i can imagine, used diction.controllers
reference angular, , did not create it.
try diction.controllers
init part with
angular.module('diction.controllers', []);
so results into
angular.module('diction.controllers', []) .controller('guestctrl', ['$scope', '$stateparams', 'auth', '$http', '$window', // logic }]);
Comments
Post a Comment