AngularJS and Breeze for IE8

http://www.breezejs.com/

by Johannes Hoppe

HTML

<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.0.3/es5-shim.js"></script>
<script src="https://code.angularjs.org/1.2.22/angular.js"></script>
<script src="https://rawgithub.com/Breeze/breeze.js/master/build/breeze.debug.js"></script>
<script src="https://rawgithub.com/Breeze/breeze.js.labs/master/breeze.angular.js"></script>
<script src="https://cdn.rawgit.com/JohannesHoppe/72d7916aeb08897bd256/raw/37d7ae8b4bf3386f9ff2a2d8122b8c2850303b2f/breeze.modelLibrary.noTrackingBackingStore.js"></script>
<div ng-controller="MyCtrl">
    This AngularJS + Breeze Demo works in IE8:
    <span ng-repeat="todo in todos" ng-bind="todo.Description"></span>
</div>

JavaScript

/* Demo for "breeze.modelLibrary.noTrackingBackingStore.js"
 * download: https://gist.github.com/JohannesHoppe/72d7916aeb08897bd256
 *
 * This is a bare version of the original backingStore,
 * without ANY change tracking - that's why it will work in IE8!
 * (Object.defineProperty not required any more)
 *
 * Hint: open this link to run the demo in IE8
 * http://jsfiddle.net/Johannes_Hoppe/bcav9hzL/5/embedded/result/
 */

angular.module('myApp',['breeze.angular'])
    .controller('MyCtrl', function($scope, breeze, entityManager) {
              
        breeze.EntityQuery.from('Todos')
            .using(entityManager)
            .using(breeze.FetchStrategy.FromLocalCache)
            .execute()
            .then(function(data) {
                $scope.todos = data.results;
            });
    })

    // CORS + IE8 is another topic, we will use the local cache instead of a real request
    .factory('entityManager', function(breeze) {
        
        var type = new breeze.EntityType({
            shortName: 'Todo',
            defaultResourceName: 'Todos',
            dataProperties: {
                Id: { dataType: breeze.DataType.Int32, isPartOfKey: true },
                Description:  { maxLength: 4000 }
            }
        });
        
        var dataService = new breeze.DataService({
            serviceName: 'nope',
            hasServerMetadata: false
        });
        
        var metadataStore = new breeze.MetadataStore();
        metadataStore.addEntityType(type);
        metadataStore.setEntityTypeForResourceName(type.shortName, type);

        var entityManager = new breeze.EntityManager({
            dataService: dataService,
            metadataStore: metadataStore
        });
        
        entityManager.createEntity('Todo', { Id: 1, Description: 'Test1 ' });
        entityManager.createEntity('Todo', { Id: 2, Description: 'Test2' });
        
        return entityManager;
    });