i have issue loading module using requirejs. i've got 2 files:
file1: app1/js/utils/commons/commons.js
define("utils/commons/commons", [ "../../../../app2/menumodule" ], function (menumodule) { //menumodule undefined here var app = angular.module('commons', ['menumodule']); }); file2: app2/menumodule.js
define("../../../../app2/menumodule", [ "../../../../app2/menucontroller", "../../../../app2/menurestprovider" ], function (menucontroller, menurestprovider) { var app = angular.module('menumodule', []); app.factory('menurestprovider', menurestprovider); app.controller('menucontroller', menucontroller); return app; }); the point is: file1 loads file2, , 'define' function file2 run. dependencies file2 not fetched, , function passed 'define' function not evaluated. can see causes problem?
i think confusing paths module ids. it's easy confuse 1 other, since paths lead defining moduleid based on how it's resloved, when put relative symbols in module reference, don't think 'going path', rather 'moving module hierarchy.
all means need share paths config can see how referenced module ids translated paths loading.
also agree: putting moduleid directly in define() call has code smell. should letting amd loader define moduleids (by making them anonymous modules.
Comments
Post a Comment