2

Master Page Controllerjs:

I am want to get following categoryId from event fired by $scope.braodcast on my event(inner) page.

$scope.RedirectToEventPage = function (categoryId) {

    var url = window.location.host + '/events';
    if (categoryId == 'ALL') {
        $rootscope.$broadcast('CategoryId', 0);
    }
    else {
        $scope.$broadcast('CategoryId', categoryId);
    }
    window.location = '/events';

};

Event Page Controllerjs: $scope.on displaying 'undefined' with console.

 knrApp.controller("EventCtrl", function ($scope, eventFactory, $rootscope) {
 $(document).ready(function () {
    $rootscope.$on('CategoryId', function (event, data) {
        if (data == null || data === undefined || data == '') {
            $scope.categoryId = 0;
        }
        else {
            $scope.categoryId = data;
        }
    });

    // $scope.categoryId = 0;
    console.log($scope.categoryId);
    $scope.GetAllEventData($scope.categoryId);
});
}
  • check some great answer regarding $rootScope here: http://stackoverflow.com/questions/19446755/on-and-broadcast-in-angular – Sk. Tajbir May 09 '16 at 20:08

0 Answers0