当我改变角度状态时停止视频

时间:2016-08-19 20:10:45

标签: angularjs html5-video

我正在角度模板中播放视频。但是当我改变状态时,视频仍在播放。

视频播放在这里:

http://localhost:8000/app/#/practice

但是当我改变这个时:

http://localhost:8000/app/#/adjust

第一个州的视频仍在播放。

有人可以帮我吗?

这是我的配置:

ErrorLog <- (code for collecting errors/warnings here) (Program Code - already completed) ErrorPopUp <- tkmessageBox(title = "ERRORS", message = paste(" Please note the following errors/warnings occurred during file processing: ", ErrorLog , "To proceed and export file please press OK. To exit the program without saving, please press cancel."), icon = "warning", type = "okcancel") (code to continue and export or quit)

这是我的index.html

.state('app.adjust',{ url: 'adjust', views:{ 'content@':{ templateUrl : 'views/adjust_lesson.html', controller : 'AdjustLesson' } } }) .state('app.practice',{ url: 'practice', views:{ 'content@':{ templateUrl : 'views/practice_lesson.html', controller: 'PracticeLesson' } } });

1 个答案:

答案 0 :(得分:3)

当'PracticeLesson'控制器被销毁时,您可以停止播放视频。

在'PracticeLesson'中输入以下代码,当你改变状态时控制器变为'AdjustLesson'时会调用它。

$scope.$on('$destroy', function() {
    // anything here will be executed when this scope is destroyed.
});