Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 视频播放事件中的角度双向绑定不';行不通_Javascript_Angularjs_Angularjs Directive - Fatal编程技术网

Javascript 视频播放事件中的角度双向绑定不';行不通

Javascript 视频播放事件中的角度双向绑定不';行不通,javascript,angularjs,angularjs-directive,Javascript,Angularjs,Angularjs Directive,我的双向bidning不起作用,如果我直接调用vm.Play()函数,它就起作用,但是当它从视频播放事件中被调用时,它就不起作用了。有人知道为什么吗 function VideoEventStats() { var directive = { restrict: "A", replace: false, scope: { videoEventStats: "=" }, controll

我的双向bidning不起作用,如果我直接调用vm.Play()函数,它就起作用,但是当它从视频播放事件中被调用时,它就不起作用了。有人知道为什么吗

function VideoEventStats() {
    var directive = {
        restrict: "A",
        replace: false,
        scope: {
            videoEventStats: "="
        },
        controller: controllerFunction,
        controllerAs: "vm",
        bindToController: true
    };

    controllerFunction.$inject = ["$element"];

    function controllerFunction($element) {
        var vm = this;

        vm.Play = Play;

        if($element.context.tagName === "VIDEO") {

            angular.element($element).on('play', vm.Play);

            $element.context.onended = function() {
                console.log('ended..');
            };
        }
        else {
            console.warn('This element is not a video element');
        }

        function Play() {
            vm.videoEventStats.CurrentUserHasSeen = true;
        }
    }

    return directive;
}

添加vm.videoEventStats.CurrentUserHasSeen=true;在一个$timeout内完成了这个把戏

function Play() { $timeout(function() { vm.videoEventStats.CurrentUserHasSeen = true; }, 0); }

添加vm.videoEventStats.CurrentUserHasSeen=true;在一个$timeout内完成了这个把戏

function Play() { $timeout(function() { vm.videoEventStats.CurrentUserHasSeen = true; }, 0); }