angularjs - inject ngRoute in requiredjs -
i tring insert angular route in angular project has requiredjs.
app.js looks this:
requirejs.config({ baseurl: 'lib', paths: { app: '../app', jquery: 'jquery-2.1.3.min', angular: 'angular', route: 'angular-route' }, shim: { 'jquery': { exports: '$' }, 'angular': { exports: 'angular' }, 'route': { deps: ['angular'], exports: 'route' } } }); // start loading main app file. put of // application logic in there. requirejs(['app/main']);
main.js looks this:
define(['route', "angular", 'app/navcontroller'], function (route, angular, navcontroller) { var app = angular.module('mainframemodule', 'ngroute'); app.controller('navcontroller', navcontroller); });
when try run web site follwing error described in: https://docs.angularjs.org/error/$injector/nomod?p0=mainframemodule
and when debug main.js, route undefined.
can me solve problem?
thanks in advance
kobi
you don't need exports
option either angular or ngroute. try shim config
shim: { 'jquery': { exports: '$' }, 'route': ['angular'] }
and main.js
define(['angular', 'app/navcontroller', 'route'], function (angular, navcontroller) { var app = angular.module('mainframemodule', 'ngroute'); app.controller('navcontroller', navcontroller); });
Comments
Post a Comment