我将entityManagerFactory注入(inject)Angular,但出现错误。就像John Papa的示例一样,这是在datacontext模块中完成的。错误是未知的提供程序。我在index.html文件中包含了EntityManagerFactory.js文件,但没有成功。有任何想法吗?

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
        };
    }
}

最佳答案

我遇到了同样的错误,解决方案很简单,并记录在John Papas博客中。

在index.html文件中,确保您具有对所有必需源文件的引用,并且它们以正确的顺序加载。

<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>

确保在entityManagerFactory.js之前加载了app.js

不要忘记在app.js中也包含对 Breeze 模块的引用。
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)
]);

关于angularjs - BreezeJS entityManagerFactory未知提供程序ASP.NET,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23839566/

10-09 18:21