0
votes

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
Wild guess, that's indicating something is looking for KnockoutJS. Presumably breeze. ko is what KnockoutJS is saved as by default.Benjamin Gruenbaum
yes but basically you can change the modellibraryli-raz

1 Answers

2
votes

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.