gpt4 book ai didi

javascript - 视频播放事件中的 Angular 2 方式绑定(bind)不起作用

转载 作者:行者123 更新时间:2023-11-28 06:18:46 25 4
gpt4 key购买 nike

我的 2 路绑定(bind)不起作用,如果我直接调用 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); }

关于javascript - 视频播放事件中的 Angular 2 方式绑定(bind)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35723111/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com