Angular the scop view dont updates may view

63 Views Asked by At

I have small app the getting data from signalR and passes them back to controller from the factory. but when the rootScope triggers and pass the object to the scope this data dosent updated on the view. here is my controller code:

(function () {
'use strict';

angular.module('app.config', ['datatables'])
    //.controller('configCtrl', configCtrl)
    .value('backendServerUrl', 'https://pmscsds01.azurewebsites.net/')
    .controller('sysCtrl', [
        "$scope", "$http", "DataConfig", "backendHubProxy", "$rootScope", function ($scope, $http, DataConfig, backendHubProxy, $rootScope) {
            DataConfig.GetConfigs();
            $rootScope.$on('data-ready', function (event, args) {
                $scope.systems = args.data;
                backendHubProxy.initalizeHub('configurationStatusClientHub', args.pcellId, $scope.systems);
            });

            $rootScope.$on('data-changed', function (event, args) {
                $scope.systems = args;
            });
        }
    ]);})();

the first $rootScope.$on is working fine but the second:

$rootScope.$on('data-changed', function (event, args) {
                $scope.systems = args;
            });

is not, it dose pass the new updated data to the systems scope but this not reflects on the view.

1

There are 1 best solutions below

0
On

I finally solve this issue just added $scope.apply();

$rootScope.$on('data-changed', function (event, args) {
            $scope.systems = args;
            $scope.apply();
        });

Now it works ;)