I am injecting the entityManagerFactory into Angular but I am getting an error. This is being done in the datacontext module just like John Papa's example. The error is unknown provider. I am including the entityManagerFactory.js file in the index.html file but no success. Any ideas?
function () {
'use strict';
var serviceId = 'datacontext';
angular.module('app').factory(serviceId, ['common', 'entityManagerFactory', 'breeze', 'logger', datacontext]);
function datacontext(common) {
var $q = common.$q;
var service = {
getPeople: getPeople,
getMessageCount: getMessageCount
};
}
}
I had the same error, the solution was simple and documented in John Papas blog.
In your index.html file, make sure that you have references to all of the required source files, and that they are loaded in the correct order.
<link href="content/breeze.directives.css" rel="stylesheet" />
<script src="scripts/breeze.debug.js"></script>
<script src="scripts/breeze.angular.js"></script>
<script src="scripts/breeze.directives.js"></script>
<script src="scripts/breeze.saveErrorExtensions.js"></script>
<script src="scripts/breeze.to$q.shim.js"></script> <!-- Needed only if you are using to$q -->
<script src="app/app.js"></script>
...
...
<script src="app/services/entityManagerFactory.js"></script>
Make sure that app.js is loaded before entityManagerFactory.js
Don't forget to include references to your breeze modules in app.js as well.
var app = angular.module('app', [
// Angular modules
'ngAnimate', // animations
'ngRoute', // routing
'ngSanitize', // sanitizes html bindings (ex: sidebar.js)
// Custom modules
'common', // common functions, logger, spinner
'common.bootstrap', // bootstrap dialog wrapper functions
// 3rd Party Modules
'breeze.angular', // configures breeze for an angular app
'breeze.directives', // contains the breeze validation directive (zValidate)
'ui.bootstrap' // ui-bootstrap (ex: carousel, pagination, dialog)
]);
If you started a new project using HotTowel.Angular.Breeze version 2.2.0, the issue you're facing may actually be a problem with the BreezeProvider, which entityManagerFactory injects.
If this is the case, you should be seeing the error:
Unknown provider: breezeProvider <- breeze <- entityManagerFactory <- datacontext
To correct this problem, make sure you have added both 'breeze.angular.js' and 'breeze.directives.js' to the index.html and added the 'breeze.angular' and 'breeze.directives' to app.js.
This will allow angular to inject the breezeProvider into entityManagerFactory, which should then be able to successfully be injected into your datacontext.
Additionally, You may find that you are missing the breeze.directives.js from the script folder and instead only have breeze.directives.validation.js. This appears to be an issue with the HotTowel.Angular.Breeze v2.2.0 Nuget package. You can fix this by installing Breeze.Angular.Directives v1.3.6 using Nuget.
PM> install-package breeze.angular.directives
Additional information and detailed instructions on this issue can be found on John Papa's blog at http://www.johnpapa.net/new-breeze-angular-service/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With