2

I am following every step of the way in John Papa's course, Building Apps with Angular and Breeze - Part 1. Once I got through the module entitled "Start playing at first clip Creating Vertical Slice Through Your App", I started to get breezeProvider errors.

Below please find error image, as well as datacontext. js code.

Your advice would be greatly appreciated.

                  -------------------------------------------

In F12 Dev Tools, the Console errors are :

Uncaught Error: Can't find breeze localhost:1772/Scripts/breeze.angular.js:90 [shell] Hot Towel Angular loaded! null

Error: [$injector:unpr] Unknown provider: breezeProvider <- breeze <- entityManagerFactory <- datacontext

[app] [CC Error] [$injector:unpr] Unknown provider: breezeProvider <- breeze <- entityManagerFactory <- datacontext

Breeze error

Here's my datacontext.js code :

(function () {
 'use strict';

var serviceId = 'datacontext';
angular.module('app').factory(serviceId, ['common', 'entityManagerFactory', datacontext]);

function datacontext(common, emFactory) {   // emFactory param refers to 'entityManagerFactory'
    var EntityQuery = breeze.EntityQuery;
    var getLogFn = common.logger.getLogFn;  
    var log = getLogFn(serviceId);          // see common\logger.js
    var logError = getLogFn(serviceId, 'error');
    var logSuccess = getLogFn(serviceId, 'success');
    var manager = emFactory.newManager();           // COMES FROM entityManagerFactory.js
    var $q = common.$q;

    var service = {
        getPeople: getPeople,
        getMessageCount: getMessageCount,
        getSessionPartials: getSessionPartials
    };

    return service;

    function getMessageCount() { return $q.when(72); }

    function getPeople() {
        var people = [
            { firstName: 'John', lastName: 'Papa', age: 25, location: 'Florida' },
            { firstName: 'Ward', lastName: 'Bell', age: 31, location: 'California' },
            { firstName: 'Colleen', lastName: 'Jones', age: 21, location: 'New York' },
            { firstName: 'Madelyn', lastName: 'Green', age: 18, location: 'North Dakota' },
            { firstName: 'Ella', lastName: 'Jobs', age: 18, location: 'South Dakota' },
            { firstName: 'Landon', lastName: 'Gates', age: 11, location: 'South Carolina' },
            { firstName: 'Haley', lastName: 'Guthrie', age: 35, location: 'Wyoming' }
        ];
        return $q.when(people);
    }

    function getSessionPartials() {            
        var orderBy = 'timeSlotId, level, speaker.firstName';
        var sessions;

        // use Breeze to get data from back end; see datacontext() function above for init code.
        return EntityQuery.from('Sessions')
            .select('id, title, code, speakerId, trackId, timeSlotId, roomId, level, tags')
            .orderBy(orderBy)
            .toType('Session')              // cast to type 'Session' (in CC.Model project)
            .using(manager).execute()       //  communicate to back end
            .then(querySucceeded, _queryFailed);
            //.to$q(querySucceeded, _queryFailed);   // OLD WAY: converts promise to Ang.

        function querySucceeded(data) {
            session = data.results;
            log('Retrieved Session Partials from remote data source', sessions.length, true);
            return sessions;
        }
        function _queryFailed(error) {  // PASSED IN BY BREEZE
            var msg = config.appErrorPrefix + 'Error retrieving data.' + error.message;  
            logError(msg, error);
            throw error;
        }
    }
 }

})();
Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
bob.mazzo
  • 5,183
  • 23
  • 80
  • 149

2 Answers2

5

The real problem is that 1st error: Can't find breeze. See that breeze.angular.js is the file that barks...

Make sure you have breeze JS file added in your index.html:

<script src="scripts/breeze.debug.js"></script> // or breeze.min.js
<script src="scripts/breeze.angular.js"></script>

If you have it already added, make sure it comes before breeze.angular.js like shown above.


These are breeze JS references I have in my app:

<!-- #region Breeze -->
<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>
<!-- #endregion -->
Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
  • That def got rid of the `Can't find breeze` error; however the rest of the error in my screen shot are still appearing ("Unknown provider: breezeProvider") – bob.mazzo Jun 11 '14 at 20:17
  • 2
    @bob: dear Bob... in this case, these additional steps should help you: http://stackoverflow.com/a/24085004/114029 My guess is that you're still missing necessary JS files in `index.html` page. – Leniel Maccaferri Jun 11 '14 at 21:15
  • thank you sir for your assistance. I'm further along now, but still getting 'query' param error which I should fix soon. I had read through http://www.johnpapa.net/new-breeze-angular-service/ some time ago, but apparently I had missed some key lines of code in app.js. – bob.mazzo Jun 11 '14 at 22:30
  • @bob: yep... from the time the course was released fast-forwarding to today things changed a little bit. – Leniel Maccaferri Jun 11 '14 at 22:35
  • I'm trying to find the FINAL version of this solution, without the use of to$q . The exercise files still use to$q . – bob.mazzo Jun 11 '14 at 22:45
  • 2
    @bob: here's what you need to change: http://www.breezejs.com/documentation/breeze-angular-service – Leniel Maccaferri Jun 11 '14 at 22:50
1

Make sure to include to include the breeze service as a dependency in the module definition:

var app = angular.module('app', [
    'ngAnimate',        
    'ngRoute',          
    'ngSanitize',       

    'breeze.angular',   // THIS IS THE MISSING DEPENDENCY

    'common',           
    'common.bootstrap', 

    'ui.bootstrap'      
]);

And Make sure that you included these files:

<script src="Scripts/breeze.debug.js"></script>
<script src="Scripts/breeze.bridge.angular.js"></script>
<script src="Scripts/breeze.directives.js"></script>
<script src="Scripts/breeze.saveErrorExtensions.js"></script>