require.js config:
require.config
paths:
jquery:"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min"
angular:"//ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular.min"
controllers:"controllers"
app:"app"
shim:
'jquery':
exports:'$'
'angular':
deps:['jquery']
exports:'angular'
'app':
deps:['angular']
exports: 'app'
'controllers':
deps:['app']
urlArgs: 'v=0.0.1'
priority: ['jquery','angular','app','controllers']
require ['angular','app','controllers'],(angular) ->
angular.element(document).ready () ->
angular.bootstrap(document,[applicationName])
app.js:
@applicationName = 'seedApp'
define ['angular'], (angular)->
app=angular.module(applicationName,[])
controller.js:
(function() {
define(['app'], function(app) {
return app.controller('versionController', [
'$scope', function($scope) {
return $scope.version = "this is controller 1";
}
]);
});
define(['app'], function(app) {
return app.controller('salamSasesc', [
'$scope', function($scope) {
return $scope.version = "this is controller 1";
}
]);
});
}).call(this);
index.jade:
extends layout
block content
h1= title
p(style="background: red;") ilie este fermecat
div(data-ng-controller="salamSasesc")
h2 {{version}}
当我使用'salamSasesc'控制器时,我收到以下错误
Argument 'salamSasesc' is not a function, got undefined
但是当我使用'versionController'时一切正常,我觉得它与AMD有关但我不确定