繁体   English   中英

角度范围没有约束力

[英]Angular scope not binding

我有这样的模板:

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

displaying something here....
</div>

在控制器中,它看起来像:

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  
    }
}])

绑定在回调中不起作用。 为什么这样?

您需要手动应用摘要循环来更新绑定,因为您从角度上下文中调用角度代码。

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

而不是超过$timeout将是更安全的运行代码的方式。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM