2016-08-19 57 views
0

我正在角模板中播放視頻。但是當我改變狀態時,視頻仍在播放。當我改變角度狀態時停止視頻

視頻播放是在這裏:

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

但是,當我改成這樣:

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

視頻在第一狀態保持播放。

任何人都可以幫助我嗎?

這是我的配置:

.state('app.adjust',{ url: 'adjust', views:{ '[email protected]':{ templateUrl : 'views/adjust_lesson.html', controller : 'AdjustLesson' } } }) .state('app.practice',{ url: 'practice', views:{ '[email protected]':{ templateUrl : 'views/practice_lesson.html', controller: 'PracticeLesson' } } });

,這是我的index.html

<div ui-view = 'header'></div> <div ui-view = 'content'></div>

回答

3

當 'PracticeLesson' 控制器被破壞,您可以停止視頻裏面。

在'PracticeLesson'中輸入以下代碼,當您更改狀態時控制器更改爲'AdjustLesson'時將調用它。

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

優秀。答案奏效了。非常感謝:D –