当我在 angular 中更改状态时停止视频
Stop video when I change the state in angular
我正在 angular 中的模板中播放视频。但是当我改变状态时,视频仍在播放。
正在播放的视频在这里:
http://localhost:8000/app/#/practice
但是当我改成这样时:
http://localhost:8000/app/#/adjust
第一个状态的视频继续播放。
有人能帮帮我吗?
这是我的配置:
.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'
}
}
});
这是我的 index.html
<div ui-view = 'header'></div>
<div ui-view = 'content'></div>
当 'PracticeLesson' 控制器被破坏时,您可以停止视频。
在'PracticeLesson'中放入以下代码,当你改变状态时控制器变为'AdjustLesson'时将被调用。
$scope.$on('$destroy', function() {
// anything here will be executed when this scope is destroyed.
});
我正在 angular 中的模板中播放视频。但是当我改变状态时,视频仍在播放。
正在播放的视频在这里:
http://localhost:8000/app/#/practice
但是当我改成这样时:
http://localhost:8000/app/#/adjust
第一个状态的视频继续播放。
有人能帮帮我吗?
这是我的配置:
.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'
}
}
});
这是我的 index.html
<div ui-view = 'header'></div>
<div ui-view = 'content'></div>
当 'PracticeLesson' 控制器被破坏时,您可以停止视频。
在'PracticeLesson'中放入以下代码,当你改变状态时控制器变为'AdjustLesson'时将被调用。
$scope.$on('$destroy', function() {
// anything here will be executed when this scope is destroyed.
});