Question

When trying to implement the session part in the tutorial of John Papa Pluralsight Video. I got the following error:

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

    }]);        
})();

It's important to know that the version of breeze that I'm working on is newer than the used on the original video.

I search for some answers on the breeze website and I've found this:

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

But I didn't make it work on the tutorial example. How to change the deprecated implementation with the new one?

UPDATE:

this link helped solve the problem:

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

Was it helpful?

Solution

The breeze library was updated and the answer is on this link: http://www.breezejs.com/documentation/breeze-angular-service

Specifically this code from the bottom of the post:

Migration is pretty painless.

  1. Remove the breeze.angular.q.js script from your project.
  2. Uninstall-Package Breeze.Angular.Q if you used NuGet.
  3. Install breeze.angular.js as explained above.
  4. Update your index.html, changing breeze.angular.q.js to breeze.angular.js.
  5. Update your app module to depend on "breeze.angular".
  6. Find the one place in your code where you call "use$q" and replace it with the "breeze" dependency.

For example, you might go from this:

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

to this:

var app = angular.module('app', [
   // ... other dependencies ...
   'breeze.angular'
]);

app.run(['breeze', function () { }]);

You should also track down and eliminate code that configures Breeze to use the "backingStore" model library adapter and $http. For example, you could go from this:

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

to this:

function configBreeze() {
    breeze.NamingConvention.camelCase.setAsDefault();

OTHER TIPS

While taking the same course by John Papa I also hit breeze.core.extendQ not available on step 4.10.

This is what I did to solve the issue:

1 - In app.js pass breeze dependency directly:

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

2 - In 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);

You can also get rid of breeze.to$q.shim.js from index.html and delete the file from the \Scripts folder in the project since it's not needed anymore.


Here's the updated source code of the same project I'm doing now [ including the fixes ].

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top