我对安古拉杰很陌生
我正在尝试将angularjs与需求集成在一起。我是如何得到错误的
Uncaught Error: No module: app
这是我的装置
main.coffee
require.config
baseUrl : "/Scripts/"
paths :
jquery : 'libs/jquery/jquery-2.0.3'
angular : 'libs/angular/angular'
'angular-resource' : 'libs/angular/angular-resource'
bootstrap : 'libs/bootstrap/bootstrap'
shim :
angular :
exports :'angular'
'angular-resource':
deps :['angular']
jquery :
exports: ['jquery']
bootstrap :
deps :['jquery']
app:
deps :['app-boot']
require ['app-angular/modules/app','app-angular/modules/app-boot'], ($,angular)->app-boot.coffee
require ['jquery','angular','bootstrap'], ($,angular)->
$(document).ready ->
angular.bootstrap document,['app'] app.coffee
define "app",['angular','angular-resource'], (angular)->
angular.module 'app',['ngResource']StudentController.coffee
require ["app"] , (app) ->
app.controller "StudentController" , ($scope) ->
$scope.msg = "Hello Joy !! How are you !! You are in Angularjs"还有我的Index.cshtml
<div class="page-content">
<div ng-controller="StudentController">
<p ng-bind="{{msg}}">
</p>
</div>
但是,它给出了错误Uncaught Error: No module: app。
我还从html中删除了ng-app,还在domready上手动引导了角。那我哪里出问题了?
发布于 2013-09-25 07:10:13
我认为您需要反转这段代码的依赖关系:
app:
deps :['app-boot']这是绕过去的路:
'app-boot': {
deps: ['app']
}app-boot.coffee文件依赖于在app.coffee文件上定义的模块app。
发布于 2013-10-03 22:40:47
看起来你在跟踪这个指南,它是双倍加好的。
我能够让它工作,但不断收到同样的错误信息,因为在我的角度控制器,'app‘没有定义。正如指南所述,'app.controller‘似乎没有设置在那里,仅仅通过'require’语句加载它就足够了:
require(['jquery', 'underscore', 'backbone', 'users', 'angular', 'directives', 'app']
这和你的只有一点不同。
/* shim */
require.config({
shim: {
underscore: {
exports: '_'
},
backbone: {
deps: ["underscore", "jquery"],
exports: "Backbone"
},
"angular":{
exports:"angular"
},
"directives":{/* this is my custom Angular directive */
deps:["angular"]
}
}
});
/* RequireJS module */
define("app", ["angular", "directives"], function(angular)
{
var app = angular.module("app", ["zipppyModule"]);
angular.element(document).ready(function()
{ angular.bootstrap(document,['zippyModule']); });
});
/* 'app' loads the module */
require(['jquery', 'underscore', 'backbone', 'users', 'angular', 'directives', 'app']https://stackoverflow.com/questions/18997457
复制相似问题