I'm using requirejs and Angular and I'm trying to create an application structure that allows me to split every controller/services/directives etc in different files. This is the structure I'd like to achieve:
src/
components/
Navigation/
index.js
module.js
NavigationController.js
NavigationService.js
In module.js I'd like to do something like this:
define(['angular', './NavigationService', './NavigationController'], function (angular, NavigationService, NavigationController) {
'use strict';
return angular.module('Myapp.Navigation', [])
.controller('NavigationController', NavigationController)
.service('NavigationService', NavigationService)
});
And having the controller/service definition defined in a separated js file.
The issue is that I don't know how to define these files. I've tried with this syntax:
//NavigationService.js
define( function() {
this.doNavigation = function () {
console.log('I am navigating');
}
});
but doesn't look to be working. Have you ever seen this kind of structure using requirejs?
Thanks!