Reputation: 423
I am playing a video in a template in angular. But when I change the state the video remains playing.
The video playing is here:
http://localhost:8000/app/#/practice
But when I change to this:
http://localhost:8000/app/#/adjust
The video in the first state remains playing.
Can anyone help me please?
This is my configuration:
.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'
}
}
});
And this is inside my index.html
<div ui-view = 'header'></div>
<div ui-view = 'content'></div>
Upvotes: 0
Views: 654
Reputation: 46
You can stop the video when 'PracticeLesson' controller is destroyed.
In 'PracticeLesson' put the following code, it will be called when the controller changes to 'AdjustLesson' when you change state.
$scope.$on('$destroy', function() {
// anything here will be executed when this scope is destroyed.
});
Upvotes: 3