2014-12-08 5 views
1

angularjs를 requirejs와 통합하려고하는데이 오류는 방화 광 콘솔에서 발생합니다. myApp is not defined ===>myApp is name of my module.각도 및 요구 사항 오류

require([ 
    "app", 
    "toaster" 
], function (app) { 

myApp.factory('newBranchRequestFactory', ['$http', 'toaster', function ($http, toaster) { 

"blah" 
    "blah" "blah" 

]); 
Factory.js

require.config({ 
    baseUrl: 'Scripts', 
    paths: { 
     'jQuery': '~/Scripts/jquery-1.11.1.min', 
     'angular': '~/Scripts/angular.min', 
     'angularAnimate': '~/Scripts/angular-animate.min', 
     'angularRoute': '~/Scripts/angular-ui-router.min', 
     'mainCtrl': '~/App/Common/Script/mainCtrl', 
     'myApp': '~/App/app', 

    }, 

    shim: { 
     angular: { 
      deps: ['jQuery'], 
      exports: 'angular' 
     }, 
     angularRoute: { 
      deps: ["angular", "angularRoute"], 
      exports: 'angularRoute' 
     }, 
     myApp: { 
      deps: ['angular'], 
      exports: 'myApp' 
     }, 

    }, 


}); 


require(['angular', 'myApp', 'MainCtrl', 'angularRoute'], function (angular) { 
    angular.bootstrap(document, ['myApp']); 
}); 

define([ 
    'angular', 
    'angularRoute', 
    'ngAnimate' 
], function (angular) { 


var myApp = angular.module('myApp', ['ngAnimate', 'ui.router']); 

    myApp.config(function ($stateProvider, $urlRouterProvider) { 

     "some rout stuff" 

}); 

app.js
main.js : 여기

내가 내 프로젝트에서 무슨 짓을했는지

오류가 발생합니다. factory.js : require is not defined?

+0

'baseUrl'을 정의하면 그에 따라 경로를 정의해야합니다. 그리고 자신의 앱 구성 요소에 대한 경로를 설정해야한다고 생각하지 않습니다. requireJS가이를 처리합니다. 내 [시작 앱 구조] (https://github.com/glepretre/angular-requirejs-ready)를 살펴보면 간단하지만 완전한 작동 예제가됩니다. – glepretre

+0

thx, 확인해 보겠습니다. –

답변

0

myApp을 app.js로 반환해야합니다.