从video.onended调用时,Angularjs $ location.path无法正常工作

时间:2014-05-26 04:27:35

标签: html5 angularjs

我想从视频开始,运行视频,然后在结束时切换到注册视图。

不幸的是,这不起作用。

控制器:

function() {
'use strict';

var controllerId = 'intro';

// create angular controller
angular.module('app').controller(controllerId, ['common', 'datacontext', '$http', '$location', '$scope', intro]);

function intro(common, datacontext, $http, $location, $scope) {

    var app = this;
    app.ready = false;

    var log = common.logger.getLogFn(controllerId);
    var logSuccess = common.logger.getLogFn(controllerId, 'success');
    var logError = common.logger.getLogFn(controllerId, 'error');

    var video = document.getElementsByTagName('video')[0];

    activate();

    $scope.changeView = function (view) {
        $location.path(view); // path not hash
    }

    video.onended = function (e) {
        // do stuff
        log('video done!');
        $location.path('/registration'); <-- this doesnt work

    }

    function activate() {
        log('Intro', null, true);
        common.activateController([], controllerId);
        $location.path('/registration'); // <---- this does work
    }


}})();

部分视图

<div ng-controller="intro as app" >
    <video width="100%" height="100%" onclick="this.play();">
        <source src="vid/intro.mp4" type="video/mp4">
    </video>
</div>

任何吸烟都会很棒!

0 个答案:

没有答案