我刚刚升级到RequireJS 2.1.1 - 我有一个AngularJS应用程序我正在加载它。在主要定义运行之前,我从角度得到“No module:app”。
它在RequireJS 2.0.1上运行正常。知道可能会有什么改变吗?
这是public / index.html
<!doctype html>
<html lang="en" ng-app="app">
<head>
<meta charset="utf-8">
<title>AngularJS</title>
<link rel="stylesheet" href="css/style.css"/>
<script data-main="main" src="requirejs/require.js"></script>
</head>
<body>
<div ng-view></div>
</body>
</html>
这是public / main.coffee
require.config
shim:
underscore: exports: '_'
ngResource:
exports: 'angular'
deps: ['angular']
angular:
exports: 'angular'
deps: ['jquery']
jquery: exports: 'jQuery'
paths:
underscore: 'underscore/index'
angular: 'AngularJS/angular'
ngResource: 'angular-modules/resource'
jquery: 'jquery/jquery'
# Bootstrap angularjs using requirejs.
define [], (require) ->
angular = require 'angular'
ngResource = require 'ngResource'
TestCtrl = require 'controllers/TestCtrl'
## ROUTER ###########
app = angular.module 'app', ['ngResource'], ($routeProvider) ->
$routeProvider.when '/test', {templateUrl: 'partials/test.html', controller: TestCtrl}
$routeProvider.otherwise {redirectTo: '/test'}
return app
答案 0 :(得分:22)
在这种情况下,您应手动引导角度并删除ng-app属性,因为dom就绪模块不可用:
angular.bootstrap document, ['app']
在定义函数的末尾
答案 1 :(得分:-1)
您需要添加此js文件:angular-resource.js