2
I am having a very strange problem and I would like if someone understands my doubt, could explain to me why it happened.
My application is a player and this one is composed by some timeouts for start and end media controls (it plays video, images, canvas, and our own media)
My html index is very simple, composed only by this:
<html ng-app="app">
<head>
<title>app</title>
<meta charset="UTF-8">
</head>
<body ng-controller="bodyCtrl" ng-keyup="processKey($event.keyCode)">
<div ng-include="page"></div>
<div class="containerMenu" ng-show="menu.isOpenned">
<div ng-include="menu.templateUrl"></div>
<span us-spinner spinner-key="spinner-1"></span>
</div>
<div ng-include="'views/fonts.html'"></div>
<div ng-include="'views/debug.html'" ng-if="isDebug"></div>
</body>
</html>
My question is this: When I insert a page within include <div ng-include="page"></div>
what happens to the controller that was already there?
For example: I have the page To and the page B, both have a controller. When I start my application I load the page To. Logic comes and logic will need to load the page B.
The page To executes a timeout when an image will be displayed:
var playImage = function(media) {
setTimeout(start, (media.duration * 1000));
}
var start = functon() {
//vai pegar a proxima imagem e mandar exibir
}
For some reason, I need to get out of the controller To who is responsible for displaying and going to the page B which is the menu controller. And then I change the include again to the page To. It is possible that because of the timeout, I have 2 instances or 2 logics running simultaneously in the controller To?
You keep the controller: bodyCtrl in the body, it will always be loaded, regardless of the page accessed. So, as you are loading a controller for each page, each page will have its controller + bodyCtrl.
– Carlos Silva