2014-03-01 92 views
8

试图在John Papa Pluralsight Video教程中实现会话部分时。 我得到了以下错误:Breeze脚本中已弃用方法的版本问题

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 website一些答案我发现这一点:

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

但我没有做它的教程示例工作。如何用新的更改已弃用的实现?

UPDATE:

此链接帮助解决问题:

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

回答

6

微风库更新,答案是这样的链接:http://www.breezejs.com/documentation/breeze-angular-service

具体的代码从底部的帖子:

迁移是非常痛苦的。

  1. 从项目中删除breeze.angular.q.js脚本。
  2. 如果您使用NuGet,请卸载软件包Breeze.Angular.Q。
  3. 如上所述安装breeze.angular.js。
  4. 更新您的index.html,将breeze.angular.q.js更改为breeze.angular.js。
  5. 更新您的应用程序模块以依赖“breeze.angular”。
  6. 找到代码中您称为“使用$ q”的地方,并用“微风”依赖关系替换它。

例如,你可以从这个去:

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() { }]); 

你也应该追查和消除配置微风使用“备份存储”模式代码库适配器和$ 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(); 
+2

谢谢!我可以在跟踪视频的同时解决同样的错误。 – tympaniplayer

+0

Hehehe ...刚刚摆脱这种'breeze.to $ q.shim.js'的时候到了这里。 –

4

虽然约翰爸爸走the same course我也打breeze.core.extendQ不提供一步4.10。

这是我做过什么来解决这个问题:

1 - 在app.jsbreeze依赖直接:

// Handle routing errors and success events 
// Trigger breeze configuration 
app.run(['$route', 'breeze', function($route, breeze) 
{ 
    // Include $route to kick start the router. 
}]); 

2 - 在datacontext.js做:

return EntityQuery.from('Sessions') 
    .select('id, title, code, speakerId, trackId, timeSlotId, roomId, level, tags') 
    .orderBy(orderBy) 
    .toType('Session') 
    .using(manager).execute() 
    .then(querySucceeded, _queryFailed); 

你也可以从index.html中删除breeze.to $ q.shim.js并从项目中的\Scripts文件夹中删除该文件因为它不再需要了。


这是我现在正在做的同一个项目[包括修复]的updated source code

+1

辉煌,非常感谢这篇文章以及您已经添加了所有更新的优秀回购。无价的工作! – JSancho

+0

此解决方案对我无效。我试过约翰帕帕的解决方案,它的工作原理。 – ATHER