Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BreezeJS entityManagerFactory Unknown Provider ASP.NET

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
        };
    }
}
like image 849
Nate Avatar asked May 23 '14 23:05

Nate


2 Answers

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)
]);
like image 123
RogerB Avatar answered Nov 09 '22 17:11

RogerB


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/

like image 26
JeremyE Avatar answered Nov 09 '22 18:11

JeremyE