Javascript 角度和要求误差
我试图将angularjs与requirejs集成,但在firebug控制台中出现了以下错误:myApp未定义==>myApp是我的模块名称 以下是我在项目中所做的: main.js app.js Factory.jsJavascript 角度和要求误差,javascript,angularjs,requirejs,Javascript,Angularjs,Requirejs,我试图将angularjs与requirejs集成,但在firebug控制台中出现了以下错误:myApp未定义==>myApp是我的模块名称 以下是我在项目中所做的: main.js app.js Factory.js 我从factory.js收到错误:未定义require?请确保在app.js中返回myApp 如果定义baseUrl,则必须根据它定义路径。我认为您不需要为自己的应用程序组件设置路径,requireJS将为您处理这些。看看我的,这是一个简单但完整的工作示例。thx,我来检查一下
我从factory.js收到错误:未定义require?请确保在app.js中返回myApp 如果定义baseUrl,则必须根据它定义路径。我认为您不需要为自己的应用程序组件设置路径,requireJS将为您处理这些。看看我的,这是一个简单但完整的工作示例。thx,我来检查一下
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"
});
require([
"app",
"toaster"
], function (app) {
myApp.factory('newBranchRequestFactory', ['$http', 'toaster', function ($http, toaster) {
"blah"
"blah" "blah"
]);