I use requirejs-rails to manage dependencies between client-side modules in my Rails 4 project.
my entry point is:
(function (define, undefined) {
'use strict';
var mainModule = function(angular, routingConfiguration, controllers) {
var restaurantsApp = angular.module('RestaurantsApplication', ['ui.router'])
.config(routingConfiguration);
angular.forEach(controllers, function(controller, name){
restaurantsApp.controller(name, controller);
});
};
define(['angular', 'application/routing-configuration',
'controllers', 'angular-ui-router'],
mainModule );
})(window.define);
but each module "injected" in define function is undefined. I mean, if I call inside define function
console.log(arguments)
I receive
[undefined, undefined, undefined, undefined]
I thought, that somewhere I have circular references, so I removed all modules except angular
(function (define, undefined) {
'use strict';
var mainModule = function(angular) {
var restaurantsApp = angular.module('RestaurantsApplication', []);
};
define(['angular'],
mainModule );
})(window.define);
but I get same result: angular is undefined.
Updated
requirejs.yml
paths:
"angular" : "angular"
"angular-ui-router" : "angular-ui-router.min"
modules:
- name: 'entry-point'
It seems, I found, what is wrong. Angular doesn't support AMD from the box.
I've configured shim in requierjs.yml like below
and, woo-hoo! it is working!