Angularjs my Breeze脚本中已弃用方法的版本问题
尝试实现John Papa Pluralsight视频教程中的会话部分时。 我得到了以下错误: 未捕获的TypeError:对象#没有方法“extendQ” 重要的是要知道我正在制作的breeze版本比原始视频中使用的版本更新 我在网上搜索了一些答案,我发现: to$q已被弃用。它被微风角服务所取代 但是我没有让它在教程示例中起作用。如何用新的实现更改不推荐使用的实现 更新: 此链接有助于解决问题:Angularjs my Breeze脚本中已弃用方法的版本问题,angularjs,breeze,q,hottowel,Angularjs,Breeze,Q,Hottowel,尝试实现John Papa Pluralsight视频教程中的会话部分时。 我得到了以下错误: 未捕获的TypeError:对象#没有方法“extendQ” 重要的是要知道我正在制作的breeze版本比原始视频中使用的版本更新 我在网上搜索了一些答案,我发现: to$q已被弃用。它被微风角服务所取代 但是我没有让它在教程示例中起作用。如何用新的实现更改不推荐使用的实现 更新: 此链接有助于解决问题: breeze库已更新,答案如下: 具体来说,这段代码来自文章的底部: 迁移是相当无痛的 从项目中
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);
}]);
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();
}
为此:
var app = angular.module('app', [
// ... other dependencies ...
'breeze.angular'
]);
app.run(['breeze', function () { }]);
function configBreeze() {
breeze.NamingConvention.camelCase.setAsDefault();
您还应该跟踪并删除配置Breeze使用“backingStore”模型库适配器和$http的代码。例如,您可以这样做:
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);
}]);
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();
}
为此:
var app = angular.module('app', [
// ... other dependencies ...
'breeze.angular'
]);
app.run(['breeze', function () { }]);
function configBreeze() {
breeze.NamingConvention.camelCase.setAsDefault();
在John Papa拍摄时,我还点击了步骤4.10中不可用的breeze.core.extendedq
这就是我为解决问题所做的:
1-在app.js
passbreeze
dependency中直接传递:
// 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
do中:
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
文件夹中删除该文件,因为它不再需要了
下面是我现在正在做的同一个项目的详细信息(包括修复)。谢谢!我能够解决同样的错误,同时跟随你的视频。呵呵。。。刚刚在这里摆脱了那股微风。到$q.shim.js。太棒了,非常感谢这张便条和你添加了所有更新的出色的回复。无价的工作!这个解决方案对我不起作用。我尝试了约翰·帕帕的解决方案,效果很好。