angularjs - 我的 Breeze 脚本中不推荐使用的方法的版本问题

标签 angularjs breeze q hottowel

在尝试实现 John Papa Pluralsight Video 教程中的 session 部分时。
我收到以下错误:

Uncaught TypeError: Object # has no method 'extendQ'


(function () {
    'use strict';

    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
        'ui.bootstrap',      // ui-bootstrap (ex: carousel, pagination, dialog)
        //'breeze.angular.q'
    ]);

    // Handle routing errors and success events
    app.run(['$route', '$rootScope', '$q', function ($route, $rootScope, $q) {
        // Include $route to kick start the router.
        breeze.core.extendQ($rootScope, $q);
        //use$q($rootScope,$q);

    }]);        
})();

重要的是要知道我正在制作的 Breeze 版本比原始视频中使用的版本更新。

我在 breeze website 上搜索一些答案我发现了这个:

The to$q has been deprecated. It is superseded by the Breeze Angular Service.



但是我没有使它在教程示例中起作用。如何用新的实现更改已弃用的实现?

更新:

这个链接帮助解决了这个问题:

http://www.breezejs.com/documentation/breeze-angular-service

最佳答案

Breeze 库已更新,答案在此链接上:http://www.breezejs.com/documentation/breeze-angular-service

特别是帖子底部的这段代码:

迁移非常轻松。

  • 从您的项目中删除 Breeze .angular.q.js 脚本。
  • 如果您使用 NuGet,请卸载 Breeze.Angular.Q。
  • 按照上面的说明安装 Breeze .angular.js。
  • 更新你的 index.html,将breath.angular.q.js 更改为breath.angular.js。
  • 更新您的应用模块以依赖“breeze.angular”。
  • 在代码中找到调用“use$q”的地方,并将其替换为“breeze”依赖项。

  • 例如,您可能会从此开始:
    var app = angular.module('app', [
       // ... other dependencies ...
       'breeze.angular.q' // tells breeze to use $q instead of Q.js
    ]);
    
    app.run(['$q','use$q', function ($q, use$q) {
           use$q($q);
    }]);
    

    对此:
    var app = angular.module('app', [
       // ... other dependencies ...
       'breeze.angular'
    ]);
    
    app.run(['breeze', function () { }]);
    

    您还应该追踪并消除将 Breeze 配置为使用“backingStore”模型库适配器和 $http 的代码。例如,您可以从此开始:
    function configBreeze($q, $http, use$q) {
        // use $q for promises
        use$q($q);
    
        // use the current module's $http for ajax calls
        var ajax = breeze.config.initializeAdapterInstance('ajax', 'angular');
        ajax.setHttp($http);
    
        // the native Breeze 'backingStore' works for Angular
        breeze.config.initializeAdapterInstance('modelLibrary', 'backingStore', true);
    
        breeze.NamingConvention.camelCase.setAsDefault();
    }
    

    对此:
    function configBreeze() {
        breeze.NamingConvention.camelCase.setAsDefault();
    

    关于angularjs - 我的 Breeze 脚本中不推荐使用的方法的版本问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22118797/

    相关文章:

    javascript - 如何在 AngularJS ng-repeat 中使用带空格的变量?

    single-page-application - 带有 WCF 数据服务的 Breeze.js

    javascript - 如何让 javascript 为 Node 中的事件队列提供服务

    node.js - 使用 Q 将 node.js fs.readFile 作为 promise 的操作

    javascript - 我该如何解决这个 Q.denodify 测试?

    javascript - 如何将工厂与 Ionic/Angular JS 和phonegap 结合使用?

    angularjs - AngularJS 组件模式绑定(bind)有特定的命名格式吗?

    javascript - 如何使用需要异步初始化的提供者配置 Angular ?

    javascript - 如何从异步函数 BreezeJS 关闭模式

    javascript - Breeze JS : Is there a way to query entities from data. 结果?