Angularjs Angular+RequireJS:无法读取未定义的属性“controller”
朋友们,我在使用RequireJS的角度时遇到了问题。以下是代码结构,以便于: main.js app.js controller.js 问题是无法读取未定义的属性“controller” 在RequireJS中,我们相信依赖关系是正确的!Angularjs Angular+RequireJS:无法读取未定义的属性“controller”,angularjs,requirejs,single-page-application,Angularjs,Requirejs,Single Page Application,朋友们,我在使用RequireJS的角度时遇到了问题。以下是代码结构,以便于: main.js app.js controller.js 问题是无法读取未定义的属性“controller” 在RequireJS中,我们相信依赖关系是正确的! 谢谢你。app.js似乎没有返回我将分析的任何内容!感谢您不要填充模块,因为它们是定义良好的RequireJS模块。Shim仅用于不兼容AMD的外部库。像angular,但不是应用程序和控制器。你是对的。谢谢,谢谢你们!问题已解决,但现在出现以下错误[$in
谢谢你。app.js似乎没有返回我将分析的任何内容!感谢您不要填充模块,因为它们是定义良好的RequireJS模块。Shim仅用于不兼容AMD的外部库。像angular,但不是应用程序和控制器。你是对的。谢谢,谢谢你们!问题已解决,但现在出现以下错误[$injector:moduler]。已包含角度资源,但错误仍然存在
require.config({
baseUrl: '/',
shim: {
angular: {
exports: "angular"
},
route: {
deps: ["angular"]
},
app:{
deps:['route']
},
controller:{
deps:['app']
}
},
paths: {
//Libery
angular: 'assets/js/lib/angular',
route: 'assets/js/lib/angular-route',
//APP
app: 'app/app',
//Controller
controller: 'app/controller/controller',
},
deps: ['controller']
});
define('app', ['angular', 'route'], function (angular, route) {
var app = angular.module('app',['ngRoute']);
app.config(function($routeProvider, $locationProvider)
{
$locationProvider.html5Mode(true);
$routeProvider
.when('/', {
templateUrl : 'app/views/home.php',
controller : 'home',
})
.when('/sobre', {
templateUrl : 'app/views/sobre.php',
controller : 'sobre',
})
.when('/contato', {
templateUrl : 'app/views/contato.php',
controller : 'contato',
})
.otherwise ({ redirectTo: '/' });
});
});
define('controller', ['app'], function (app) {
app.controller('home', function($rootScope, $location){
$rootScope.activetab = $location.path();
});
app.controller('sobre', function($rootScope, $location){
$rootScope.activetab = $location.path();
});
app.controller('contato', function($rootScope, $location){
$rootScope.activetab = $location.path();
});
});