1

I have a template like this:

    <div class="modal top am-fade-and-slide-top" tabindex="-1" role="dialog"
 style="display: block;" ng-init="bindHide($hide)">

displaying something here....
</div>

And in the controller, it's looks like:

angular.module('coreApp').controller('incomingCallController',['$scope','$rootScope','$http','$ocLazyLoad','$modal',function($scope,$rootScope,$http,$lazyLoad,$modal){
    var session = $rootScope.videoSession;
    //$rootScope.videoSession.accept();

    $scope.callerData =
    {
        'username': $rootScope.videoSession.request.getHeader('userName'),
        'profileimage':  $rootScope.videoSession.request.getHeader('profileImage')
    }
    $scope.rejectCall = function(){
        session.reject();
    }

    session.on('cancel',function(){
        $scope.hideModal(); //-----------Doesn't work here
    });

    $scope.bindHide = function(hideModal){
        $scope.hideModal = hideModal;

        //$scope.hideModal() ---- works fine here  
    }
}])

The binding doesn't work in the callback. Why so?

0

1 Answer 1

3

You need to apply digest cycle manually to update bindings, because you are calling angular code from out of angular context.

Code

session.on('cancel',function(){
    $scope.$apply(function(){
        $scope.hideModal();
    })
});

Rather than above $timeout would be more safer way to run the code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.