Take the 2-minute tour ×

I am trying to use breeze to do the same calls that work using angualar's $http. For some reason the $scope does not appear to work in the breeze callback.


<!DOCTYPE html>
<html ng-app="">
<body ng-controller="TextController">
            <li ng-repeat="patient in patients">     
    <script src="/scripts/jquery-1.8.2.js"></script>
    <script src="/scripts/q.js"></script>
    <script src="/scripts/breeze.min.js"></script>
    <script src="/Scripts/angular.js"></script>
    <script type="text/javascript">

        function TextController($scope, $http){

            var serviceName = "/api/breeze";
            var manager = new breeze.EntityManager(serviceName);
            var query = breeze.EntityQuery.from("Patients");

            $scope.textData1 = "Waiting..";
            $scope.textData2 = "Waiting..";

                then(function (data) {
                    $scope.textData1 = 'Breeze';
                    //$scope.patients = [];
                    //$scope.patients = data;
                fail(function(error) {
                    $scope.textData1 = error.message;

            $http({ method: 'GET', url: '/api/patients' }).
                      $scope.textData2 = 'Angular';
                      //$scope.patients = [];
                      //$scope.patients = data;

In the above code both the angular $http call and the breeze calls return data as I print it to the console. When this is run only the textData2 binding updates to 'Angular' the textData1 binding does not update to 'Breeze'. I'm in the function as the console gets called but the binding does not update. The same thing happens if I try to bind the list of data the the 'patients' reference in the scope. I commented that out to show the simplest version of my problem.

Make sense? Thoughts?


share|improve this question
You might want to try calling $apply in the breeze callback. –  tosh shimayama Apr 23 '13 at 2:17
That did it. Any idea why it's required in the breeze but not the angular callback? –  Brian Apr 23 '13 at 2:55
docs.angularjs.org/api/ng.$rootScope.Scope#$apply Simply put, angularJs does not actively keep watching the value, it uses notification mechanism which get invoked by every function that may change the scope value. It has to be triggered if something happens outside of angular framework. –  tosh shimayama Apr 23 '13 at 3:03
add comment


Your Answer



Browse other questions tagged or ask your own question.