Using Angular with breeze and require

不羁的心 提交于 2019-12-25 03:41:16

问题


i am trying to use angular with breeze and requireJS how ever i am getting error of Uncaught Error: Module name "ko" has not been loaded yet for context: _. Use require([])

i have configured

define("breezeConfig", ["breeze"], function(breeze) {
// configure to use the model library for Angular
//breeze.config.initializeAdapterInstance({ dataService: "OData" });
breeze.config.initializeAdapterInstance("modelLibrary", "backingStore", true);

// configure to use camelCase
breeze.NamingConvention.camelCase.setAsDefault();

var serverAddress = "/odata/";
var manager = new breeze.EntityManager(serverAddress);
return breeze;

});

and in the main module

require.config({
baseUrl: "/app",
paths: {
    "jQuery": "lib/jquery-1.8.2",
    "angular": "lib/angular",
    "angular-resource": "lib/angular-resource",
    "text": "lib/text",
    "Q": "lib/q",
    "breeze": "lib/breeze.min"
 and so on

at the end

require([
'jQuery',
'Q',
'breeze',
'angular',
'app',
'controllers',
'routes',
'breezeConfig'

], function ($, angular, app) {

angular.element(document).ready(function () {
    angular.bootstrap(document, ['AMail']);
});

where am i wrong?


回答1:


Yes ... we know. It's been reported on S.O. before. We have a fix on the way (next release).

Meanwhile, inside your main module do two things:

1) define a bogus knockout module

define('ko', function() {}); // do nothing

2) add a shim to your require.config function:

...
shim: {
       jquery: { exports: '$' },
       angular: { exports: 'angular' },
       breeze: { deps: ['ko', 'jquery', 'Q'] }
      }
...

You'll need the shim (minus the 'ko' dependency!) even after we fix the ko problem. Breeze depends on 'jquery' and 'Q' which must be loaded first. You may or may not need the other shim lines.



来源:https://stackoverflow.com/questions/16657894/using-angular-with-breeze-and-require

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!